Transform接口说明

作者:追风剑情 发布于:2017-10-27 16:22 分类:Unity3d

//模型正前方的世界坐标
public Vector3 forward { get; set; }
//本地坐标转世界坐标
public Vector3 TransformDirection(Vector3 direction);
public Vector3 TransformDirection(float x, float y, float z);
public Vector3 TransformPoint(Vector3 position);
public Vector3 TransformPoint(float x, float y, float z);
public Vector3 TransformVector(Vector3 vector);
public Vector3 TransformVector(float x, float y, float z);

//世界坐标转本地坐标
public Vector3 InverseTransformDirection(Vector3 direction);
public Vector3 InverseTransformDirection(float x, float y, float z);
public Vector3 InverseTransformPoint(Vector3 position);
public Vector3 InverseTransformPoint(float x, float y, float z);
public Vector3 InverseTransformVector(Vector3 vector);
public Vector3 InverseTransformVector(float x, float y, float z);

//平移
public void Translate(Vector3 translation);
public void Translate(Vector3 translation, Space relativeTo);
public void Translate(Vector3 translation, Transform relativeTo);
public void Translate(float x, float y, float z);
public void Translate(float x, float y, float z, Space relativeTo);
public void Translate(float x, float y, float z, Transform relativeTo);

//旋转
public void Rotate(Vector3 eulerAngles);
public void Rotate(Vector3 axis, float angle);
public void Rotate(Vector3 eulerAngles, Space relativeTo);
public void Rotate(float xAngle, float yAngle, float zAngle);
public void Rotate(Vector3 axis, float angle, Space relativeTo);
public void Rotate(float xAngle, float yAngle, float zAngle, Space relativeTo);

//朝向
public void LookAt(Transform target);
public void LookAt(Vector3 worldPosition);
public void LookAt(Transform target, Vector3 worldUp);
public void LookAt(Vector3 worldPosition, Vector3 worldUp);

//查找
public Transform Find(string name);
public Transform FindChild(string name);
public Transform GetChild(int index);
public IEnumerator GetEnumerator();

//解除父子关系
public void DetachChildren();

//是否为parent的子节点
public bool IsChildOf(Transform parent);

//设置父节点
public void SetParent(Transform parent);
//worldPositionStays true:保持子节点原来的旋转及缩放(即,不受父节点的变化影响)
public void SetParent(Transform parent, bool worldPositionStays);

//处理兄弟节点位置
public int GetSiblingIndex();
public void SetAsFirstSibling();
public void SetAsLastSibling();
public void SetSiblingIndex(int index);

--------------------------------------------------------------------- 分割线 -------------------------------------------------------------------

//因为Transform类实现了IEnumerable接口,所以可直接遍历(非递归)
foreach (Transform child in transform)
{
    Debug.Log(child.name);
}


标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号