Unity之Transform组件详解

介绍:

每个对象都有一个变换。 它用于存储和操作对象的位置、旋转和缩放。 每个变换都可以有一个父级。(position,rotate, 缩放)

成员变量:

childCount

父变换具有的子项数。

eulerAngles

以欧拉角表示的旋转(以度为单位)。

forward

返回一个标准化矢量,它表示世界空间中变换的蓝轴。

hasChanged

自上次将标志设置为“false”以来,变换是否发生更改?

hierarchyCapacity

变换的层级视图数据结构的变换容量。

hierarchyCount

变换的层级视图数据结构中变换的数量。

localEulerAngles

以欧拉角表示的相对于父变换旋转的旋转(以度为单位)。

localPosition

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

localRotation

相对于父级变换旋转的变换旋转。

localScale

相对于 GameObjects 父对象的变换缩放。

localToWorldMatrix

将点从本地空间转换到世界空间的矩阵(只读)。

lossyScale

对象的全局缩放。(只读)

parent

变换的父级。

position

世界空间中的变换位置。

right

世界空间中变换的红轴。

root

返回层级视图中最顶层的变换。

rotation

一个 Quaternion,用于存储变换在世界空间中的旋转。

up

世界空间中变换的绿轴。

worldToLocalMatrix

将点从世界空间转换到本地空间的矩阵(只读)。

gameObject

此组件附加到的游戏对象。始终将组件附加到游戏对象。

tag

此游戏对象的标签。

transform

附加到此 GameObject 的 Transform。

hideFlags

该对象应该隐藏、随场景一起保存还是由用户修改?

name

对象的名称。

成员函数(方法):

方法名;          参数;            返回值类型 ;          作用;

Find

String name

transform

找到的子项转换。如果未找到具有匹配名称的子项,则为 Null。

GetChild

int index

transform

按索引返回变换子项。

GetSiblingIndex

int

获取同级索引。

InverseTransformDirection

Vector3 direction

Vector3

将 direction 从世界空间变换到本地空间。与 Transform.TransformDirection 相反。该操作不受缩放影响。

InverseTransformPoint

Vector3 position

Vector3

将 position 从世界空间变换到本地空间。

InverseTransformVector

将 vector 从世界空间变换到本地空间。与 Transform.TransformVector 相反。

IsChildOf

Transform parent

bool

该变换是否为 parent 的子项?

LookAt

Transform target

[ Vector3 worldUp]

void

旋转变换,使向前矢量指向 target 的当前位置。

worldUp指定向上方向的矢量。

Rotate

Vector3 eulers

[Space.Self]

void

使用 Transform.Rotate 以各种方式旋转 GameObjects。通常以欧拉角而不是四元数提供旋转。

RotateAround

Vector3 pointVector3 axis, float angle

void

将变换围绕穿过世界坐标中的 point 的 axis 旋转 angle 度。

SetAsFirstSibling

将变换移动到本地变换列表的开头。

SetAsLastSibling

将变换移动到本地变换列表的末尾。

SetParent

Transform parent,

void

设置变换的父级。

SetPositionAndRotation

 (Vector3 positionQuaternion rotation)

void

设置变换组件的世界空间位置和旋转。

SetSiblingIndex

设置同级索引。

TransformDirection

 (Vector3 direction)

void

将 direction 从本地空间变换到世界空间。

该操作不受变换的缩放或位置的影响。 返回的矢量与 direction 的长度相同。

TransformPoint

 (Vector3 position )

void

将 position 从本地空间变换到世界空间。

返回的位置受缩放影响。如果要处理方向矢量,请使用 Transform.TransformDirection

TransformVector TransformVector

Vector3

void

将 vector 从本地空间变换到世界空间。

该操作不受变换的位置的影响,但受缩放影响。 返回的矢量可能具有与 vector 不同的长度。

Translate

Vector3 translation   Space.Self(World)

void

根据 translation 的方向和距离移动变换。

Instantiate

参数:

GameObject,(必选)

Position新对象的位置。

Parent新对象的父对象。

Rotation新对象的方向。

作用:克隆 original 对象并返回克隆对象。

  • 13
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值