Class TransformExtensions
Inheritance
Namespace: TetraCreations.Core
Assembly: cs.temp.dll.dll
Syntax
public static class TransformExtensions
Methods
AddScale(Transform, float, float, float)
Add values to curent local scale of the transform.
Declaration
public static void AddScale(this Transform transform, float x = 0, float y = 0, float z = 0)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
float | x | |
float | y | |
float | z |
AddToPosition(Transform, float, float, float)
Add values to the current position of the transform.
Declaration
public static void AddToPosition(this Transform transform, float x = 0, float y = 0, float z = 0)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
float | x | |
float | y | |
float | z |
AddToRotation(Transform, float, float, float)
Add values to the current local rotation of the transform.
Declaration
public static void AddToRotation(this Transform transform, float x = 0, float y = 0, float z = 0)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
float | x | |
float | y | |
float | z |
DestroyChildren(Transform, Func<Transform, bool>)
Destroy all children of the transform. If we pass a predicate, it needs to be true to actually destroy the child.
Declaration
public static void DestroyChildren(this Transform transform, Func<Transform, bool> predicate = null)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
Func<, ><Transform, bool> | predicate | Predicate function to exclude some children from being destroyed (If false). |
DestroyChildrenImmediately(Transform, Func<Transform, bool>)
Destroy immediately all children of the transform inside the editor. If we pass a predicate, it needs to be true to actually destroy the child.
Declaration
public static void DestroyChildrenImmediately(this Transform transform, Func<Transform, bool> predicate = null)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
Func<, ><Transform, bool> | predicate | Predicate function to exclude some children from being destroyed (If false). |
DisableChildren(Transform)
Disables all child game objects of the given transform.
Declaration
public static void DisableChildren(this Transform parent)
Parameters
Type | Name | Description |
---|---|---|
Transform | parent | The Transform whose child game objects are to be disabled. |
EnableChildren(Transform)
Enables all child game objects of the given transform.
Declaration
public static void EnableChildren(this Transform parent)
Parameters
Type | Name | Description |
---|---|---|
Transform | parent | The Transform whose child game objects are to be enabled. |
ForEachChild(Transform, Action<Transform>)
Executes an action for each child of a given transform.
Declaration
public static void ForEachChild(this Transform parent, Action<Transform> action)
Parameters
Type | Name | Description |
---|---|---|
Transform | parent | The transform |
Action<><Transform> | action | The action to be performed on each child |
Remarks
This method iterates over all child transforms in reverse order and executes a given action on them. The action is a delegate that takes a Transform as parameter.
GetChild(Transform, int)
Get child Transform by index, return null if the index is out of range.
Declaration
public static Transform GetChild(this Transform transform, int index)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
int | index |
Returns
Type | Description |
---|---|
Transform |
GetChildrenTransforms(Transform, List<Transform>)
Get every childreen transforms recursively
Declaration
public static void GetChildrenTransforms(this Transform parent, List<Transform> children)
Parameters
Type | Name | Description |
---|---|---|
Transform | parent | |
List<><Transform> | children |
GetComponentInChildren<T>(Transform, int)
Declaration
public static T GetComponentInChildren<T>(this Transform transform, int index)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
int | index |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
GetFirstChildrenTransforms(Transform)
Get children transforms at the fist level in the hierarchy.
Declaration
public static List<Transform> GetFirstChildrenTransforms(this Transform parent)
Parameters
Type | Name | Description |
---|---|---|
Transform | parent |
Returns
Type | Description |
---|---|
List<><Transform> |
Log(Transform)
Show all the transform values in the console (Position, LocalRotation, Scale)
Declaration
public static void Log(this Transform transform)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform |
LogEulerAngles(Transform)
Show the transform local rotation euler angles values in the console
Declaration
public static void LogEulerAngles(this Transform transform)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform |
LogPosition(Transform)
Show the transform position values in the console
Declaration
public static void LogPosition(this Transform transform)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform |
LogScale(Transform)
Show the transform local scale values in the console
Declaration
public static void LogScale(this Transform transform)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform |
LookAt2D(Transform, Transform)
Makes the transform look at a 2D target object by rotating its Up-axis towards the target position.
Declaration
public static void LookAt2D(this Transform transform, Transform target)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | The transform to look at the target. |
Transform | target | The target transform to look at. |
Reset(Transform)
Set position (0,0,0), localRotation to Quaternion.identity and localeScale to (1,1,1).
Declaration
public static void Reset(this Transform transform)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform |
ResetLocalRotation(Transform)
Set the local rotation to "no rotation" - the object is perfectly aligned with the world or parent axes.
Declaration
public static void ResetLocalRotation(this Transform transform)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform |
SetPosition(Transform, float?, float?, float?)
Set position values of the transform.
Declaration
public static void SetPosition(this Transform transform, float? x = null, float? y = null, float? z = null)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
float? | x | |
float? | y | |
float? | z |
SetPositionToZero(Transform)
Set position to (0,0,0)
Declaration
public static void SetPositionToZero(this Transform transform)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform |
SetRotation(Transform, float?, float?, float?)
Set rotation values of the transform.
Declaration
public static void SetRotation(this Transform transform, float? x = null, float? y = null, float? z = null)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
float? | x | |
float? | y | |
float? | z |
SetScale(Transform, float?, float?, float?)
Set scale values of the transform.
Declaration
public static void SetScale(this Transform transform, float? x = null, float? y = null, float? z = null)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
float? | x | |
float? | y | |
float? | z |
SetScaleAllAxes(Transform, float)
Set the local scale for all axes.
Declaration
public static void SetScaleAllAxes(this Transform transform, float scaling)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform | |
float | scaling |
SetScaleToOne(Transform)
Set the local scale to (1,1,1)
Declaration
public static void SetScaleToOne(this Transform transform)
Parameters
Type | Name | Description |
---|---|---|
Transform | transform |