Skip to content

API > Transform


Transform⚓︎

Transform inherits from Component

Position, rotation and scale of an object. Unity Transform

Members⚓︎

Properties⚓︎

Name Description
Transform.childCountPropertyReadonly Property The number of children the parent Transform has.
Transform.eulerAnglesProperty The rotation as Euler angles in degrees.
Transform.forwardPropertyReadonly Property Returns a normalized vector representing the blue axis of the transform in world space.
Transform.hasChangedProperty Has the transform changed since the last time the flag was set to 'false'?
Transform.hierarchyCapacityProperty The transform capacity of the transform's hierarchy data structure.
Transform.hierarchyCountProperty The number of transforms in the transform's hierarchy data structure.
Transform.localEulerAnglesProperty The rotation as Euler angles in degrees relative to the parent transform's rotation.
Transform.localPositionProperty Position of the transform relative to the parent transform.
Transform.localRotationProperty The rotation of the transform relative to the transform rotation of the parent.
Transform.localScaleProperty The scale of the transform relative to the GameObjects parent.
Transform.lossyScalePropertyReadonly Property The global scale of the object (Read Only).
Transform.parentProperty The parent of the transform.
Transform.positionProperty The world space position of the Transform.
Transform.rightProperty The red axis of the transform in world space.
Transform.rootProperty Returns the topmost transform in the hierarchy.
Transform.rotationProperty
Transform.upProperty The green axis of the transform in world space.

Methods⚓︎

Name Description
Transform.DetachChildren() Method Unparents all children.
Transform.Find(n) Method Finds a child by n and returns it.
Transform.GetChild(index) Method Returns a transform child by index.
Transform.GetSiblingIndex() Method Gets the sibling index.
Transform.InverseTransformDirection(direction) Method Transforms a direction from world space to local space. The opposite of Transform.TransformDirection.
Transform.InverseTransformPoint(position) Method Transforms position from world space to local space.
Transform.InverseTransformVector(vector) Method Transforms a vector from world space to local space. The opposite of Transform.TransformVector.
Transform.IsChildOf(parent) Method Is this transform a child of parent?
Transform.LookAt(target, worldUp=Vector3.up) Method Rotates the transform so the forward vector points at /target/'s current position.
Transform.Rotate(eulers, relativeTo=Space.Self) Method 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) Method Rotates the transform about axis passing through point in world coordinates by angle degrees.
Transform.SetAsFirstSibling() Method Move the transform to the start of the local transform list.
Transform.SetAsLastSibling() Method Move the transform to the end of the local transform list.
Transform.SetParent(parent) Method Set the parent of the transform.
Transform.SetParent(parent, worldPositionStays) Method Set the parent of the transform.
Transform.SetPositionAndRotation(position, rotation) Method Sets the world space position and rotation of the Transform component.
Transform.SetSiblingIndex(index) Method Sets the sibling index.
Transform.TransformDirection(direction) Method Transforms direction from local space to world space.
Transform.TransformPoint(position) Method Transforms position from local space to world space.
Transform.TransformVector(vector) Method Transforms vector from local space to world space.
Transform.Translate(translation, relativeTo=Space.Self) Method Moves the transform in the direction and distance of translation.

Inherited Members⚓︎

Inherited Properties⚓︎

Name Description
Transform.gameObjectPropertyReadonly Property The game object this component is attached to. A component is always attached to a game object.
Transform.tagPropertyReadonly Property The tag of this game object.
Transform.transformPropertyReadonly Property The Transform attached to this GameObject.
Transform.hideFlagsProperty Should the object be hidden, saved with the Scene or modifiable by the user?
Transform.nameProperty The name of the object.

Inherited Methods⚓︎

Name Description
Transform.BroadcastMessage(methodName, parameter=nil)Method Calls the method named methodName on every Lua Script in this game object or any of its children.
Transform.CompareTag(tag)Method Is this game object tagged with tag ?
Transform.GetAllLuaScripts()Method Returns an array of all Lua scripts that attached to the game object.
Transform.GetComponent(type)Method Returns the component of Type type if the game object has one attached, nil if it doesn't.
Transform.GetComponentInChildren(t)Method Returns the component of Type type in the GameObject or any of its children using depth first search.
Transform.GetComponentInParent(t)Method Returns the component of Type type in the GameObject or any of its parents.
Transform.GetComponents(type)Method Returns all components of Type type in the GameObject.
Transform.GetComponentsInChildren(t)Method Returns all components of Type type in the GameObject or any of its children.
Transform.GetComponentsInParent(t)Method Returns all components of Type type in the GameObject or any of its parents.
Transform.SendMessage(methodName, value=nil)Method Calls the method named methodName on every Lua Script in this game object.
Transform.SendMessageUpwards(methodName, value=nil)Method Calls the method named methodName on every LuaScript in this game object and on every ancestor of the behaviour.
Transform.TryGetComponent(type)Method Gets the component of the specified type, if it exists.
Transform.GetInstanceID()Method 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: