英文原本地址:http://docs.unity3d.com/ScriptReference/Transform.html


Transform 变换


Namespace: UnityEngine

Inherits from: Component


Description 描述


Position, rotation and scale of an object.

对象的位置、旋转和缩放。

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:

场景中的每一个对象都有一个Transform。用于储存并操控物体的位置、旋转和缩放。每一个Transform可以有一个父级,允许你分层次应用位置、旋转和缩放。可以在Hierarchy面板查看层次关系。他们也支持计数器(enumerator),因此你可以使用循环遍历子对象。

JavaScript:

for (var child : Transform in transform) 
{ 
	child.position += Vector3.up * 10.0; 
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void Example() {
        foreach (Transform child in transform) {
            child.position += Vector3.up * 10.0F;
        }
    }
}

See Also: The Component reference, Physics class.


Variables 变量


childCount

The number of children the Transform has.

该变换的子对象数量。

eulerAngles

The rotation as Euler angles in degrees.

此旋转作为欧拉角度。

forward

The blue axis of the transform in world space.

在世界空间坐标,变换的蓝色轴。也就是z轴。

hasChanged

Has the transform changed since the last time the flag was set to 'false'?

此变换自从上次标识是否被设置为false了?

localEulerAngles

The rotation as Euler angles in degrees relative to the parent transform's rotation.

旋转作为欧拉角度,相对于父级的变换旋转。

localPosition

Position of the transform relative to the parent transform.

相对于父级的变换的位置。

localRotation

The rotation of the transform relative to the parent transform's rotation.

该变换的旋转角度相对于父级变换的旋转角度。

localScale

The scale of the transform relative to the parent.

相对于父级变换的缩放。

localToWorldMatrix

Matrix that transforms a point from local space into world space (Read Only).

变换点的矩阵从局部坐标到世界坐标(只读)。

lossyScale

The global scale of the object (Read Only).

该对象的整体缩放(只读)。

parent

The parent of the transform. 

该变换的父对象。

position

The position of the transform in world space.

在世界空间坐标transform的位置。

right

The red axis of the transform in world space.

在世界坐标空间,变换的红色轴。也就是x轴。

root

Returns the topmost transform in the hierarchy. 

返回最高层级的变换。

rotation

The rotation of the transform in world space stored as a Quaternion.

在世界坐标空间,储存为四元数变换的旋转角度。

up

The green axis of the transform in world space.

在世界坐标空间,变换的绿色轴。也就是Y轴。

worldToLocalMatrix

Matrix that transforms a point from world space into local space (Read Only).

变换点的矩阵从世界坐标到局部坐标(只读)。


Functions 函数


DetachChildren

Unparents all children.、

所有子对象解除父子关系。

Find

Finds a child by name and returns it.

通过名字查找子对象并返回它。

GetChild

Returns a transform child by index.

通过索引返回一个变换的子对象。

GetSiblingIndex

Gets the sibling index.

获取该对象的同级索引。

InverseTransformDirection

Transforms a direction from world space to local space. The opposite of Transform.TransformDirection.

变换的方向从世界坐标转换到局部坐标。和Transform.TransformDirection相反。

InverseTransformPoint

Transforms position from world space to local space. The opposite of Transform.TransformPoint.

变换位置从世界坐标到局部坐标。和Transform.TransformPoint相反。

InverseTransformVector

Transforms a vector from world space to local space. The opposite of Transform.TransformVector.

变换一个向量从世界坐标空间到局部坐标空间。这个操作与Transform.TransformVector相反。

IsChildOf

Is this transform a child of /parent/?

这个变换是parent的子对象?

LookAt

Rotates the transform so the forward vector points at /target/'s current position. 

旋转此变换,让向前向量指向target的当前位置。

Rotate

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).

应用一个欧拉角的旋转角度,eulerAngles.z度围绕z轴,eulerAngles.x度围绕x轴,eulerAngles.y度围绕y轴(这样的顺序)。

RotateAround

Rotates the transform about axis passing through point in world coordinates by angle degrees.

围绕世界坐标的point点的axis旋转该变换angle度。

SetAsFirstSibling

Move the transform to the start of the local transfrom list.

移动该变换到此局部变换列表的开始。

SetAsLastSibling

Move the transform to the end of the local transfrom list.

移动该变换到此局部变换列表的末尾。

SetParent

Set the parent of the transform.

设置该变换的父级。

SetSiblingIndex

Sets the sibling index.

设置同级对象的索引。

TransformDirection

Transforms direction from local space to world space.

变换方向从局部坐标转换到世界坐标。

TransformPoint

Transforms position from local space to world space.

变换位置从局部坐标到世界坐标。

TransformVector

Transforms vector from local space to world space. \\变换一个向量从局部坐标空间到世界坐标空间。

Translate

Moves the transform in the direction and distance of translation. 

移动transform在translation的方向和距离。