API > Transform
Transform⚓︎
Transform inherits from Component
Position, rotation and scale of an object. Unity Transform
Members⚓︎
Properties⚓︎
Name | Description |
---|---|
Transform .childCount |
The number of children the parent Transform has. |
Transform .eulerAngles |
The rotation as Euler angles in degrees. |
Transform .forward |
Returns a normalized vector representing the blue axis of the transform in world space. |
Transform .hasChanged |
Has the transform changed since the last time the flag was set to 'false'? |
Transform .hierarchyCapacity |
The transform capacity of the transform's hierarchy data structure. |
Transform .hierarchyCount |
The number of transforms in the transform's hierarchy data structure. |
Transform .localEulerAngles |
The rotation as Euler angles in degrees relative to the parent transform's rotation. |
Transform .localPosition |
Position of the transform relative to the parent transform. |
Transform .localRotation |
The rotation of the transform relative to the transform rotation of the parent. |
Transform .localScale |
The scale of the transform relative to the GameObjects parent. |
Transform .lossyScale |
The global scale of the object (Read Only). |
Transform .parent |
The parent of the transform. |
Transform .position |
The world space position of the Transform. |
Transform .right |
The red axis of the transform in world space. |
Transform .root |
Returns the topmost transform in the hierarchy. |
Transform .rotation |
|
Transform .up |
The green axis of the transform in world space. |
Methods⚓︎
Name | Description |
---|---|
Transform .DetachChildren() |
Unparents all children. |
Transform .Find(n) |
Finds a child by n and returns it. |
Transform .GetChild(index) |
Returns a transform child by index. |
Transform .GetSiblingIndex() |
Gets the sibling index. |
Transform .InverseTransformDirection(direction) |
Transforms a direction from world space to local space. The opposite of Transform.TransformDirection. |
Transform .InverseTransformPoint(position) |
Transforms position from world space to local space. |
Transform .InverseTransformVector(vector) |
Transforms a vector from world space to local space. The opposite of Transform.TransformVector. |
Transform .IsChildOf(parent) |
Is this transform a child of parent? |
Transform .LookAt(target, worldUp=Vector3.up) |
Rotates the transform so the forward vector points at /target/'s current position. |
Transform .Rotate(eulers, relativeTo=Space.Self) |
Applies a rotation of eulerAngles.z degrees around the z-axis, eulerAngles.x degrees around the x-axis, and eulerAngles.y degrees around the y-axis (in that order). |
Transform .RotateAround(point, axis, angle) |
Rotates the transform about axis passing through point in world coordinates by angle degrees. |
Transform .SetAsFirstSibling() |
Move the transform to the start of the local transform list. |
Transform .SetAsLastSibling() |
Move the transform to the end of the local transform list. |
Transform .SetParent(parent) |
Set the parent of the transform. |
Transform .SetParent(parent, worldPositionStays) |
Set the parent of the transform. |
Transform .SetPositionAndRotation(position, rotation) |
Sets the world space position and rotation of the Transform component. |
Transform .SetSiblingIndex(index) |
Sets the sibling index. |
Transform .TransformDirection(direction) |
Transforms direction from local space to world space. |
Transform .TransformPoint(position) |
Transforms position from local space to world space. |
Transform .TransformVector(vector) |
Transforms vector from local space to world space. |
Transform .Translate(translation, relativeTo=Space.Self) |
Moves the transform in the direction and distance of translation. |
Inherited Members⚓︎
Inherited Properties⚓︎
Name | Description |
---|---|
Transform .gameObject |
The game object this component is attached to. A component is always attached to a game object. |
Transform .tag |
The tag of this game object. |
Transform .transform |
The Transform attached to this GameObject. |
Transform .hideFlags |
Should the object be hidden, saved with the Scene or modifiable by the user? |
Transform .name |
The name of the object. |
Inherited Methods⚓︎
Name | Description |
---|---|
Transform .BroadcastMessage(methodName, parameter=nil) |
Calls the method named methodName on every Lua Script in this game object or any of its children. |
Transform .CompareTag(tag) |
Is this game object tagged with tag ? |
Transform .GetAllLuaScripts() |
Returns an array of all Lua scripts that attached to the game object. |
Transform .GetComponent(type) |
Returns the component of Type type if the game object has one attached, nil if it doesn't. |
Transform .GetComponentInChildren(t) |
Returns the component of Type type in the GameObject or any of its children using depth first search. |
Transform .GetComponentInParent(t) |
Returns the component of Type type in the GameObject or any of its parents. |
Transform .GetComponents(type) |
Returns all components of Type type in the GameObject. |
Transform .GetComponentsInChildren(t) |
Returns all components of Type type in the GameObject or any of its children. |
Transform .GetComponentsInParent(t) |
Returns all components of Type type in the GameObject or any of its parents. |
Transform .SendMessage(methodName, value=nil) |
Calls the method named methodName on every Lua Script in this game object. |
Transform .SendMessageUpwards(methodName, value=nil) |
Calls the method named methodName on every LuaScript in this game object and on every ancestor of the behaviour. |
Transform .TryGetComponent(type) |
Gets the component of the specified type, if it exists. |
Transform .GetInstanceID() |
Returns the instance id of the object. |
Extra Detail⚓︎
Every object in a Scene has a Transform. It's used to store and manipulate the position, rotation and scale of the object. Every Transform can have a parent, which allows you to apply position, rotation and scale hierarchically. This is the hierarchy seen in the Hierarchy pane. They also support enumerators so you can loop through children using: