Class TransformExtensions
Inheritance
Inherited Members
Namespace: Liminal.SDK.Extensions
Assembly: Liminal.SDK.dll
Syntax
public static class TransformExtensions
Methods
| Improve this Doc View SourceGetOrAddComponent(Transform, Type)
Declaration
public static Component GetOrAddComponent(this Transform transform, Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.Transform | transform | |
| System.Type | type |
Returns
| Type | Description |
|---|---|
| UnityEngine.Component |
GetOrAddComponent<T>(Transform)
Returns the component of the specified type on the transform, or if the component does not exist, adds it to the transform's GameObject and then returns the new component.
Declaration
public static T GetOrAddComponent<T>(this Transform transform)
where T : Component
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.Transform | transform | The transform to retrieve the component from or add the component to. |
Returns
| Type | Description |
|---|---|
| T | The existing component of the specified type on |
Type Parameters
| Name | Description |
|---|---|
| T | The component type |
HasComponent<T>(Transform)
Returns a boolean value indicating if the specified Transform has a component of the specified type.
Declaration
public static bool HasComponent<T>(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.Transform | transform | The transform to operate on. |
Returns
| Type | Description |
|---|---|
| System.Boolean | A boolean value indicating if the supplied UnityEngine.Transform has a component of the specified type. |
Type Parameters
| Name | Description |
|---|---|
| T | The component type |
Identity(Transform)
Resets the transform to its identity state, where UnityEngine.Transform.localPosition is equal to UnityEngine.Vector3.zero, UnityEngine.Transform.localRotation is equal to UnityEngine.Quaternion.identity and UnityEngine.Transform.localScale is equal to UnityEngine.Vector3.one.
Declaration
public static void Identity(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.Transform | transform | The transform to reset to its identity state. |
IsDescendentOf(Transform, Transform)
Indicates if this Transform is a descendent of the supplied ancestor Transform.
Declaration
public static bool IsDescendentOf(this Transform transform, Transform ancestor)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.Transform | transform | The transform. |
| UnityEngine.Transform | ancestor | The ancestor transform. |
Returns
| Type | Description |
|---|---|
| System.Boolean | A boolean value indicating if this Transform is a descendent of the supplied ancestor Transform. |
SetParentAndIdentity(Transform, Transform)
Sets the parent of the transform and resets it to its identity state once it has been reparented. This is synonymous with calling UnityEngine.Transform.SetParent(UnityEngine.Transform) followed by Identity(Transform).
Declaration
public static void SetParentAndIdentity(this Transform transform, Transform parent)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.Transform | transform | The transform to reparent. |
| UnityEngine.Transform | parent | The new parent of |