-
Notifications
You must be signed in to change notification settings - Fork 0
Transform Extensions
Sets the X-coordinate of the transform's position.
transform.SetPositionX(2.0f);Parameters:
-
x: The new X-coordinate.
Sets the Y-coordinate of the transform's position.
transform.SetPositionY(-1.0f);Parameters:
-
y: The new Y-coordinate.
Sets the Z-coordinate of the transform's position.
transform.SetPositionZ(5.0f);Parameters:
-
z: The new Z-coordinate.
Sets the X and Y coordinates of the transform's position.
transform.SetPositionXY(2.0f, -1.0f);Parameters:
-
x: The new X-coordinate. -
y: The new Y-coordinate.
Sets the X and Z coordinates of the transform's position.
transform.SetPositionXZ(2.0f, 5.0f);Parameters:
-
x: The new X-coordinate. -
z: The new Z-coordinate.
Sets the Y and Z coordinates of the transform's position.
transform.SetPositionYZ(-1.0f, 5.0f);Parameters:
-
y: The new Y-coordinate. -
z: The new Z-coordinate.
Gets the X-coordinate of the transform's position.
float x = transform.GetPositionX();Returns:
-
x: The X-coordinate of the position.
Gets the Y-coordinate of the transform's position.
float y = transform.GetPositionY();Returns:
-
y: The Y-coordinate of the position.
Gets the Z-coordinate of the transform's position.
float z = transform.GetPositionZ();Returns:
-
z: The Z-coordinate of the position.
Gets the X and Y coordinates of the transform's position as a Vector2.
Vector2 xy = transform.GetPositionXY();Returns:
-
xy: The X and Y coordinates as a Vector2.
Gets the X and Z coordinates of the transform's position as a Vector2.
Vector2 xz = transform.GetPositionXZ();Returns:
-
xz: The X and Z coordinates as a Vector2.
Gets the Y and Z coordinates of the transform's position as a Vector2.
Vector2 yz = transform.GetPositionYZ();Returns:
-
yz: The Y and Z coordinates as a Vector2.
Gets the X-component of the transform's rotation.
float x = transform.GetRotationX();Returns:
-
x: The X-component of the rotation.
Gets the Y-component of the transform's rotation.
float y = transform.GetRotationY();Returns:
-
y: The Y-component of the rotation.
Gets the Z-component of the transform's rotation.
float z = transform.GetRotationZ();Returns:
-
z: The Z-component of the rotation.
Gets the W-component of the transform's rotation.
float w = transform.GetRotationW();Returns:
-
w: The W-component of the rotation.
Sets the X-component of the transform's rotation.
transform.SetRotationX(45.0f);Parameters:
-
x: The new X-component of the rotation.
Sets the Y-component of the transform's rotation.
transform.SetRotationY(180.0f);Parameters:
-
y: The new Y-component of the rotation.
Sets the Z-component of the transform's rotation.
transform.SetRotationZ(-90.0f);Parameters:
-
z: The new Z-component of the rotation.
Sets the W-component of the transform's rotation.
transform.SetRotationW(0.5f);Parameters:
-
w: The new W-component of the rotation.
Gets the X-component of the transform's Euler angles.
float x = transform.GetEulerAnglesX();Returns:
-
x: The X-component of the Euler angles.
Gets the Y-component of the transform's Euler angles.
float y = transform.GetEulerAnglesY();Returns:
-
y: The Y-component of the Euler angles.
Gets the Z-component of the transform's Euler angles.
float z = transform.GetEulerAnglesZ();Returns:
-
z: The Z-component of the Euler angles.
Gets the X and Y components of the transform's Euler angles as a Vector2.
Vector2 xy = transform.GetEulerAnglesXY();Returns:
-
xy: The X and Y components as a Vector2.
Gets the X and Z components of the transform's Euler angles as a Vector2.
Vector2 xz = transform.GetEulerAnglesXZ();Returns:
-
xz: The X and Z components as a Vector2.
Gets the Y and Z components of the transform's Euler angles as a Vector2.
Vector2 yz = transform.GetEulerAnglesYZ();Returns:
-
yz: The Y and Z components as a Vector2.
Sets the X-component of the transform's Euler angles.
transform.SetEulerAnglesX(30.0f);Parameters:
-
x: The new X-component of the Euler angles.
Sets the Y-component of the transform's Euler angles.
transform.SetEulerAnglesY(-45.0f);Parameters:
-
y: The new Y-component of the Euler angles.
Sets the Z-component of the transform's Euler angles.
transform.SetEulerAnglesZ(90.0f);Parameters:
-
z: The new Z-component of the Euler angles.
Sets the X and Y components of the transform's Euler angles.
transform.SetEulerAnglesXY(30.0f, -45.0f);Parameters:
-
x: The new X-component of the Euler angles. -
y: The new Y-component of the Euler angles.
Sets the X and Z components of the transform's Euler angles.
transform.SetEulerAnglesXZ(30.0f, 90.0f);Parameters:
-
x: The new X-component of the Euler angles. -
z: The new Z-component of the Euler angles.
Sets the Y and Z components of the transform's Euler angles.
transform.SetEulerAnglesYZ(-45.0f, 90.0f);Parameters:
-
y: The new Y-component of the Euler angles. -
z: The new Z-component of the Euler angles.
Sets the X-coordinate of the transform's local position.
transform.SetLocalPositionX(2.0f);Parameters:
-
x: The new X-coordinate.
Sets the Y-coordinate of the transform's local position.
transform.SetLocalPositionY(-1.0f);Parameters:
-
y: The new Y-coordinate.
Sets the Z-coordinate of the transform's local position.
transform.SetLocalPositionZ(5.0f);Parameters:
-
z: The new Z-coordinate.
Sets the X and Y coordinates of the transform's local position.
transform.SetLocalPositionXY(2.0f, -1.0f);Parameters:
-
x: The new X-coordinate. -
y: The new Y-coordinate.
Sets the X and Z coordinates of the transform's local position.
transform.SetLocalPositionXZ(2.0f, 5.0f);Parameters:
-
x: The new X-coordinate. -
z: The new Z-coordinate.
Sets the Y and Z coordinates of the transform's local position.
transform.SetLocalPositionYZ(-1.0f, 5.0f);Parameters:
-
y: The new Y-coordinate. -
z: The new Z-coordinate.
Gets the X-coordinate of the transform's local position.
float x = transform.GetLocalPositionX();Returns:
-
x: The X-coordinate of the local position.
Gets the Y-coordinate of the transform's local position.
float y = transform.GetLocalPositionY();Returns:
-
y: The Y-coordinate of the local position.
Gets the Z-coordinate of the transform's local position.
float z = transform.GetLocalPositionZ();Returns:
-
z: The Z-coordinate of the local position.
Gets the X and Y coordinates of the transform's local position as a Vector2.
Vector2 xy = transform.GetLocalPositionXY();Returns:
-
xy: The X and Y coordinates as a Vector2.
Gets the X and Z coordinates of the transform's local position as a Vector2.
Vector2 xz = transform.GetLocalPositionXZ();Returns:
-
xz: The X and Z coordinates as a Vector2.
Gets the Y and Z coordinates of the transform's local position as a Vector2.
Vector2 yz = transform.GetLocalPositionYZ();Returns:
-
yz: The Y and Z coordinates as a Vector2.
Gets the X-component of the transform's local rotation.
float x = transform.GetLocalRotationX();Returns:
-
x: The X-component of the local rotation.
Gets the Y-component of the transform's local rotation.
float y = transform.GetLocalRotationY();Returns:
-
y: The Y-component of the local rotation.
Gets the Z-component of the transform's local rotation.
float z = transform.GetLocalRotationZ();Returns:
-
z: The Z-component of the local rotation.
Gets the W-component of the transform's local rotation.
float w = transform.GetLocalRotationW();Returns:
-
w: The W-component of the local rotation.
Sets the X-component of the transform's local rotation.
transform.SetLocalRotationX(45.0f);Parameters:
-
x: The new X-component of the local rotation.
Sets the Y-component of the transform's local rotation.
transform.SetLocalRotationY(-90.0f);Parameters:
-
y: The new Y-component of the local rotation.
Sets the Z-component of the transform's local rotation.
transform.SetLocalRotationZ(180.0f);Parameters:
-
z: The new Z-component of the local rotation.
Sets the W-component of the transform's local rotation.
transform.SetLocalRotationW(0.5f);Parameters:
-
w: The new W-component of the local rotation.
Gets the X-component of the transform's local Euler angles.
float x = transform.GetLocalEulerAnglesX();Returns:
-
x: The X-component of the local Euler angles.
Gets the Y-component of the transform's local Euler angles.
float y = transform.GetLocalEulerAnglesY();Returns:
-
y: The Y-component of the local Euler angles.
Gets the Z-component of the transform's local Euler angles.
float z = transform.GetLocalEulerAnglesZ();Returns:
-
z: The Z-component of the local Euler angles.
Sets the X-component of the transform's local Euler angles.
transform.SetLocalEulerAnglesX(30.0f);Parameters:
-
x: The new X-component of the local Euler angles.
Sets the Y-component of the transform's local Euler angles.
transform.SetLocalEulerAnglesY(-45.0f);**Parameters
:**
-
y: The new Y-component of the local Euler angles.
Sets the Z-component of the transform's local Euler angles.
transform.SetLocalEulerAnglesZ(90.0f);Parameters:
-
z: The new Z-component of the local Euler angles.
Sets the X and Y components of the transform's local Euler angles.
transform.SetLocalEulerAnglesXY(30.0f, -45.0f);Parameters:
-
x: The new X-component of the local Euler angles. -
y: The new Y-component of the local Euler angles.
Sets the X and Z components of the transform's local Euler angles.
transform.SetLocalEulerAnglesXZ(30.0f, 90.0f);Parameters:
-
x: The new X-component of the local Euler angles. -
z: The new Z-component of the local Euler angles.
Sets the Y and Z components of the transform's local Euler angles.
transform.SetLocalEulerAnglesYZ(-45.0f, 90.0f);Parameters:
-
y: The new Y-component of the local Euler angles. -
z: The new Z-component of the local Euler angles.
Sets the X component of the transform's local scale.
transform.SetLocalScaleX(2.0f);Parameters:
-
x: The new X component of the local scale.
Sets the Y component of the transform's local scale.
transform.SetLocalScaleY(0.5f);Parameters:
-
y: The new Y component of the local scale.
Sets the Z component of the transform's local scale.
transform.SetLocalScaleZ(1.5f);Parameters:
-
z: The new Z component of the local scale.
Sets the X and Y components of the transform's local scale.
transform.SetLocalScaleXY(2.0f, 0.5f);Parameters:
-
x: The new X component of the local scale. -
y: The new Y component of the local scale.
Sets the X and Z components of the transform's local scale.
transform.SetLocalScaleXZ(2.0f, 1.5f);Parameters:
-
x: The new X component of the local scale. -
z: The new Z component of the local scale.
Sets the Y and Z components of the transform's local scale.
transform.SetLocalScaleYZ(0.5f, 1.5f);Parameters:
-
y: The new Y component of the local scale. -
z: The new Z component of the local scale.
Gets the X component of the transform's local scale.
float x = transform.GetLocalScaleX();Returns:
-
x: The X component of the local scale.
Gets the Y component of the transform's local scale.
float y = transform.GetLocalScaleY();Returns:
-
y: The Y component of the local scale.
Gets the Z component of the transform's local scale.
float z = transform.GetLocalScaleZ();Returns:
-
z: The Z component of the local scale.
Gets the X and Y components of the transform's local scale as a Vector2.
Vector2 xy = transform.GetLocalScaleXY();Returns:
-
xy: The X and Y components as a Vector2.
Gets the X and Z components of the transform's local scale as a Vector2.
Vector2 xz = transform.GetLocalScaleXZ();Returns:
-
xz: The X and Z components as a Vector2.
Gets the Y and Z components of the transform's local scale as a Vector2.
Vector2 yz = transform.GetLocalScaleYZ();Returns:
-
yz: The Y and Z components as a Vector2.
Retrieves or adds a component of a specified type to the transform.
var myComponent = transform.GetOrAddComponent<MyComponentType>();Parameters:
-
transform: The transform to retrieve or add the component to.
Returns:
-
myComponent: The retrieved or added component.
Retrieves or adds a component of a specified type to the transform.
var myComponent = transform.GetOrAddComponent(typeof(MyComponentType));Parameters:
-
transform: The transform to retrieve or add the component to. -
type: The type of the component.
Returns:
-
myComponent: The retrieved or added component.
Tries to get a component of a specified type from the transform or its ancestors.
bool success = someTransform.TryGetComponentInHierarchy(out SomeComponentType myComponent);Parameters:
-
context: The transform to retrieve the component from. -
target: The retrieved component.
Returns:
-
success: True if the component was found, false otherwise.
Finds a component of a specified type in the transform or its ancestors.
var myComponent = someTransform.FindComponentInParents<MyComponentType>();Parameters:
-
transform: The transform to retrieve the component from.
Returns:
-
myComponent: The retrieved component, or null if not found.
Retrieves all children of the transform that have a component of a specified type.
List<MyComponentType> childrenWithComponent = someTransform.GetAllChild<MyComponentType>();Parameters:
-
transform: The transform to retrieve the children from.
Returns:
-
childrenWithComponent: A list of children with the specified component.
Finds a child of the transform with a specified name using a fuzzy search.
Transform foundChild = someTransform.FindInAllChildFuzzy("PartialName");Parameters:
-
transform: The transform to retrieve the child from. -
name: The name of the child. -
includeInactive: Whether to include inactive children.
Returns:
-
foundChild: The child with the specified name, or null if not found.
Finds a child of the transform with a specified name.
Transform foundChild = someTransform.FindInAllChild("ExactName");Parameters:
-
transform: The transform to retrieve the child from. -
name: The name of the child. -
includeInactive: Whether to include inactive children.
Returns:
-
foundChild: The child with the specified name, or null if not found.
Performs an action on each child of the transform.
someTransform.ForeachChild(child => Debug.Log(child.name));Parameters:
-
transform: The transform to perform the action on its children. -
action: The action to perform.
Returns:
-
transform: The transform.
Updates the children of the transform based on a specified count and updater function.
someTransform.UpdateChild(5, (index, child) => child.localScale = new Vector3(index + 1, index + 1, index + 1));Parameters:
-
transform: The transform to update its children. -
count: The number of children to update. -
updater: The function to update the children.
Returns:
-
transform: The transform.
Destroys all children of the transform.
someTransform.DestroyChildren();Parameters:
-
transform: The transform to destroy its children.
Returns:
-
transform: The transform.
Calculates the screen position of the transform.
Vector2 screenPos = someTransform.ScreenPosition();Parameters:
-
transform: The transform to calculate the screen position for.
Returns:
-
screenPos: A Vector2 representing the screen position of the transform.
Calculates the screen position ratio of the transform.
Vector2 screenPosRatio = someTransform.ScreenPositionRatio();Parameters:
-
transform: The transform to calculate the screen position ratio for.
Returns:
-
screenPosRatio: A Vector2 representing the screen position ratio of the transform.
Copies the transform values from a source transform to the current transform.
someTransform.CopyTransform(sourceTransform, true);Parameters:
-
transform: The transform to copy values to. -
src: The source transform to copy values from. -
isWordSpace: If true, copies the world position and rotation. If false, copies the local position and rotation.
Returns:
-
transform: The transform with copied values.
Retrieves the path of the transform in the hierarchy.
string transformPath = someTransform.Path();Parameters:
-
transform: The transform to retrieve the path for.
Returns:
-
transformPath: A string representing the path of the transform in the hierarchy.
Retrieves the full path of the transform in the hierarchy, including the transform's name.
string fullTransformPath = someTransform.PathFull();Parameters:
-
transform: The transform to retrieve the full path for.
Returns:
-
fullTransformPath: A string representing the full path of the transform in the hierarchy.
Retrieves the root transform of the current transform.
Transform rootTransform = someTransform.Root();Parameters:
-
go: The transform to retrieve the root for.
Returns:
-
rootTransform: The root transform of the current transform.
Calculates the depth of the transform in the hierarchy.
int transformDepth = someTransform.Depth();Parameters:
-
transform: The transform to calculate the depth for.
Returns:
-
transformDepth: An integer representing the depth of the transform in the hierarchy.
Determines whether the transform is within the view of the specified camera.
bool isInView = someTransform.IsInView(Camera.main);Parameters:
-
transform: The transform to check. -
camera: The camera to check the view for.
Returns:
-
isInView: True if the transform is in the view of the camera, false otherwise.