Show / Hide Table of Contents

Method GetOrAddComponent

| Edit this page View Source

GetOrAddComponent<T>(GameObject)

Returns the component of Type type. If one doesn't already exist on the GameObject it will be added.
Declaration
public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
Parameters
Type Name Description
GameObject gameObject The GameObject this Component is attached to.
Returns
Type Description
T Component
Type Parameters
Name Description
T The type of Component to return.
Remarks
Source: https://wiki.unity3d.com/index.php/GetOrAddComponent
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Generated by DocFX
☀
☾