Skip to main content

Transform

info

Transform inherits from Component

Position, rotation and scale of an object. Unity Transform

Members

Properties

NameDescription
Transform.childCountThe number of children the parent Transform has.
Transform.eulerAnglesThe rotation as Euler angles in degrees.
Transform.forwardReturns a normalized vector representing the blue axis of the transform in world space.
Transform.hasChangedHas the transform changed since the last time the flag was set to 'false'?
Transform.hierarchyCapacityThe transform capacity of the transform's hierarchy data structure.
Transform.hierarchyCountThe number of transforms in the transform's hierarchy data structure.
Transform.localEulerAnglesThe rotation as Euler angles in degrees relative to the parent transform's rotation.
Transform.localPositionPosition of the transform relative to the parent transform.
Transform.localRotationThe rotation of the transform relative to the transform rotation of the parent.
Transform.localScaleThe scale of the transform relative to the GameObjects parent.
Transform.lossyScaleThe global scale of the object (Read Only).
Transform.parentThe parent of the transform.
Transform.positionThe world space position of the Transform.
Transform.rightThe red axis of the transform in world space.
Transform.rootReturns the topmost transform in the hierarchy.
Transform.rotation
Transform.upThe green axis of the transform in world space.

Methods

NameDescription
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

NameDescription
Transform.gameObjectThe game object this component is attached to. A component is always attached to a game object.
Transform.tagThe tag of this game object.
Transform.transformThe Transform attached to this GameObject.
Transform.hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
Transform.nameThe name of the object.

Inherited Methods

NameDescription
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: