矩形的位置、大小、锚点和轴心信息。
RectTransforms 用于 GUI,不过也可以用于其他情况。
它用于存储和操作矩形的位置、大小和锚定,并支持各种形式的缩放(基于父 RectTransform)。
注意:Inspector 基于在使用哪个锚点预设对公开哪些属性进行更改。有关更多信息,请参阅矩形变换和基本布局。
anchoredPosition | 此 RectTransform 的轴心相对于锚点参考点的位置。 |
anchoredPosition3D | 此 RectTransform 的轴心相对于锚点参考点的 3D 位置。 |
anchorMax | 父 RectTransform 中右上角锚定到的标准化位置。 |
anchorMin | 父 RectTransform 中左下角锚定到的标准化位置。 |
drivenByObject | 驱动此 RectTransform 的值的对象。如果未驱动,则值为 null。 |
offsetMax | 矩形右上角相对于右上锚点的偏移。 |
offsetMin | 矩形左下角相对于左下锚点的偏移。 |
pivot | 此 RectTransform 中围绕其旋转的标准化位置。 |
rect | Transform 的本地空间中计算的矩形。 |
sizeDelta | 此 RectTransform 相对于锚点之间距离的大小。 |
ForceUpdateRectTransforms | 强制重新计算 RectTransform 内部数据。 |
GetLocalCorners | 获取计算的矩形在其 Transform 的本地空间中的各个角。 |
GetWorldCorners | 获取计算的矩形在世界空间中的各个角。 |
SetInsetAndSizeFromParentEdge | 设置此矩形相对于父矩形指定边缘的距离,同时也会设置其大小。 |
SetSizeWithCurrentAnchors | 使 RectTransform 计算的矩形在指定轴上具有给定大小。 |
reapplyDrivenProperties | 为需要重新应用其驱动属性的 RectTransform 调用的事件。 |
ReapplyDrivenProperties | 用于 reapplyDrivenProperties 事件的委托。 |
gameObject | 此组件附加到的游戏对象。始终将组件附加到游戏对象。 |
tag | 此游戏对象的标签。 |
transform | 附加到此 GameObject 的 Transform。 |
hideFlags | 该对象应该隐藏、随场景一起保存还是由用户修改? |
name | 对象的名称。 |
childCount | 父变换具有的子项数。 |
eulerAngles | 以欧拉角表示的旋转(以度为单位)。 |
forward | 返回一个标准化矢量,它表示世界空间中变换的蓝轴。 |
hasChanged | 自上次将标志设置为“false”以来,变换是否发生更改? |
hierarchyCapacity | 变换的层级视图数据结构的变换容量。 |
hierarchyCount | 变换的层级视图数据结构中变换的数量。 |
localEulerAngles | 以欧拉角表示的相对于父变换旋转的旋转(以度为单位)。 |
localPosition | 相对于父变换的变换位置。 |
localRotation | 相对于父级变换旋转的变换旋转。 |
localScale | 相对于 GameObjects 父对象的变换缩放。 |
localToWorldMatrix | 将点从本地空间转换到世界空间的矩阵(只读)。 |
lossyScale | 对象的全局缩放。(只读) |
parent | 变换的父级。 |
position | 世界空间中的变换位置。 |
right | 世界空间中变换的红轴。 |
root | 返回层级视图中最顶层的变换。 |
rotation | 一个 Quaternion,用于存储变换在世界空间中的旋转。 |
up | 世界空间中变换的绿轴。 |
worldToLocalMatrix | 将点从世界空间转换到本地空间的矩阵(只读)。 |
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 using depth first search. Works recursively. |
GetComponentsInParent | 返回 GameObject 或其任何父项中类型为 type 的所有组件。 |
SendMessage | 调用此游戏对象中的每个 MonoBehaviour 上名为 methodName 的方法。 |
SendMessageUpwards | 调用此游戏对象中的每个 MonoBehaviour 上或此行为的每个父级上名为 methodName 的方法。 |
TryGetComponent | 获取指定类型的组件(如果存在)。 |
GetInstanceID | Gets the instance ID of the object. |
ToString | 返回对象的名称。 |
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 的方向和距离移动变换。 |
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 == | 比较两个对象引用,判断它们是否引用同一个对象。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.