对象的位置、旋转和缩放。
场景中的每个对象都有一个变换。 它用于存储和操作对象的位置、旋转和缩放。 每个变换都可以有一个父级,让您能够分层应用位置、旋转和缩放。这是“Hierarchy”面板中显示的层级视图。 它们还支持枚举器,因此您可以使用以下方式遍历子项:
using UnityEngine;
public class Example : MonoBehaviour { // Moves all transform children 10 units upwards! void Start() { foreach (Transform child in transform) { child.position += Vector3.up * 10.0f; } } }
| childCount | 父变换具有的子项数。 |
| eulerAngles | 以欧拉角表示的旋转(以度为单位)。 |
| forward | 返回一个标准化矢量,它表示世界空间中变换的蓝轴。 |
| hasChanged | 自上次将标志设置为“false”以来,变换是否发生更改? |
| hierarchyCapacity | 变换的层级视图数据结构的变换容量。 |
| hierarchyCount | 变换的层级视图数据结构中变换的数量。 |
| localEulerAngles | 以欧拉角表示的相对于父变换旋转的旋转(以度为单位)。 |
| localPosition | 相对于父变换的变换位置。 |
| localRotation | 相对于父级变换旋转的变换旋转。 |
| localScale | 相对于 GameObjects 父对象的变换缩放。 |
| localToWorldMatrix | 将点从本地空间转换到世界空间的矩阵(只读)。 |
| lossyScale | 对象的全局缩放。(只读) |
| parent | 变换的父级。 |
| position | 世界空间中的变换位置。 |
| right | 世界空间中变换的红轴。 |
| root | 返回层级视图中最顶层的变换。 |
| rotation | 一个 Quaternion,用于存储变换在世界空间中的旋转。 |
| up | 世界空间中变换的绿轴。 |
| worldToLocalMatrix | 将点从世界空间转换到本地空间的矩阵(只读)。 |
| DetachChildren | 清除所有子项的父级。 |
| Find | Finds a child by name n and returns it. |
| GetChild | 按索引返回变换子项。 |
| GetSiblingIndex | 获取同级索引。 |
| InverseTransformDirection | 将 direction 从世界空间变换到本地空间。与 Transform.TransformDirection 相反。 |
| InverseTransformPoint | 将 position 从世界空间变换到本地空间。 |
| InverseTransformVector | 将 vector 从世界空间变换到本地空间。与 Transform.TransformVector 相反。 |
| IsChildOf | 该变换是否为 parent 的子项? |
| LookAt | 旋转变换,使向前矢量指向 target 的当前位置。 |
| Rotate | 使用 Transform.Rotate 以各种方式旋转 GameObjects。通常以欧拉角而不是四元数提供旋转。 |
| RotateAround | 将变换围绕穿过世界坐标中的 point 的 axis 旋转 angle 度。 |
| SetAsFirstSibling | 将变换移动到本地变换列表的开头。 |
| SetAsLastSibling | 将变换移动到本地变换列表的末尾。 |
| SetParent | 设置变换的父级。 |
| SetPositionAndRotation | 设置变换组件的世界空间位置和旋转。 |
| SetSiblingIndex | 设置同级索引。 |
| TransformDirection | 将 direction 从本地空间变换到世界空间。 |
| TransformPoint | 将 position 从本地空间变换到世界空间。 |
| TransformVector | 将 vector 从本地空间变换到世界空间。 |
| Translate | 根据 translation 的方向和距离移动变换。 |
| gameObject | 此组件附加到的游戏对象。始终将组件附加到游戏对象。 |
| tag | 此游戏对象的标签。 |
| transform | 附加到此 GameObject 的 Transform。 |
| hideFlags | 该对象应该隐藏、随场景一起保存还是由用户修改? |
| name | 对象的名称。 |
| BroadcastMessage | 调用此游戏对象或其任何子项中的每个 MonoBehaviour 上名为 methodName 的方法。 |
| CompareTag | Checks the GameObject's tag against the defined tag. |
| GetComponent | Returns the component of type if the GameObject has one attached. |
| GetComponentInChildren | Returns the Component of type in the GameObject or any of its children using depth first search. |
| GetComponentInParent | Returns the Component of type in the GameObject or any of its parents. |
| GetComponents | 返回 GameObject 中类型为 type 的所有组件。 |
| GetComponentsInChildren | Returns all components of Type type in the GameObject or any of its children. Works recursively. |
| GetComponentsInParent | 返回 GameObject 或其任何父项中类型为 type 的所有组件。 |
| SendMessage | 调用此游戏对象中的每个 MonoBehaviour 上名为 methodName 的方法。 |
| SendMessageUpwards | 调用此游戏对象中的每个 MonoBehaviour 上或此行为的每个父级上名为 methodName 的方法。 |
| TryGetComponent | 获取指定类型的组件(如果存在)。 |
| GetInstanceID | Gets the instance ID of the object. |
| ToString | 返回对象的名称。 |
| Destroy | 移除 GameObject、组件或资源。 |
| DestroyImmediate | 立即销毁对象 /obj/。强烈建议您改用 Destroy。 |
| DontDestroyOnLoad | 在加载新的 Scene 时,请勿销毁 Object。 |
| FindObjectOfType | 返回第一个类型为 type 的已加载的激活对象。 |
| FindObjectsOfType | Gets a list of all loaded objects of Type type. |
| Instantiate | 克隆 original 对象并返回克隆对象。 |
| bool | 该对象是否存在? |
| operator != | 比较两个对象是否引用不同的对象。 |
| operator == | 比较两个对象引用,判断它们是否引用同一个对象。 |