Class GameObjectExtensions
Inheritance
System.Object
GameObjectExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Liminal.SDK.Extensions
Assembly: Liminal.SDK.dll
Syntax
public static class GameObjectExtensions
Methods
| Improve this Doc View SourceGetOrAddComponent(GameObject, Type)
Declaration
public static Component GetOrAddComponent(this GameObject gameObject, Type type)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.GameObject | gameObject | |
System.Type | type |
Returns
Type | Description |
---|---|
UnityEngine.Component |
GetOrAddComponent<T>(GameObject)
Gets the component of the specified type from a GameObject. If the component does not exist, it will be added to the GameObject and then returned.
Declaration
public static T GetOrAddComponent<T>(this GameObject gameObject)
where T : Component
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.GameObject | gameObject | The GameObject to get the component from, or add the component to. |
Returns
Type | Description |
---|---|
T | The component of the specified type. |
Type Parameters
Name | Description |
---|---|
T | The type of the component |
HasComponent<T>(GameObject)
Returns a boolean value indicating if the specified GameObject has a component of the specified type.
Declaration
public static bool HasComponent<T>(this GameObject gameObject)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.GameObject | gameObject | The GameObject to operate on. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean value indicating if the supplied UnityEngine.GameObject has a component of the specified type. |
Type Parameters
Name | Description |
---|---|
T | The component type |