1、位置
transforn.position 世界位置
transform.localPosition 相對父類位置
在屏幕左上方顯示方法:
private void OnGUI()
{
GUILayout.Label(string.Format("position is {0}",transform.position));
}
2、角度
歐拉角:
transform.eularAngles
transform.localEulerAngles 相對父類坐標
四元數旋轉角度:
transform.rotation 世界坐標
transform.localRotation 相對父類坐標
需要注意的是,Unity Transform的Rotation中所填數據為歐拉角
轉換方法:
transform.rotation = Quaternion.Euler(0,0,0);
3、縮放
transform.lossyScale 世界坐標
transform.localScale 相對父類坐標
4、其他
方向向量:
transform.right 為X軸
transform.up 為Y軸
transform.forward 為Z軸
transfrom.right 返回值為Vector3(0,0,0) 類型
父類子類層級關系:
transform.parent 父類 transform.parent.name 返回父類的名稱
transform.root 根物體 transform.root.name 返回根物體的名稱
transform.childCount 子類數量
子物體為該物體下一級的物體,再深一層的物體不屬於該物體的子類