2 回答
TA贡献1853条经验 获得超6个赞
不,不是内置的,但我会推荐一个合适的类型
[Serializable]
public class TransformData
{
public Vector3 LocalPosition = Vector3.zero;
public Vector3 LocalEulerRotation = Vector3.zero;
public Vector3 LocalScale = Vector3.one;
// Unity requires a default constructor for serialization
public TransformData() { }
public TransformData(Transform transform)
{
LocalPosition = transform.localPosition;
LocalEulerRotation = transform.localEulerAngles;
LocalScale = transform.localScale;
}
public void ApplyTo(Transform transform)
{
transform.localPosition = LocalPosition;
transform.localEulerAngles = LocalEulerRotation ;
transform.localScale = LocalScale;
}
}
并像使用它
public GameObject Obj02;
public GameObject Obj04;
private TransformData transformDataOfObj02;
private TransformData transformDataOfObj04;
void Start()
{
transformDataOfObj02 = new TransformData(Obj02.transform);
transformDataOfObj04 = new TransformData(Obj04.transform);
}
以后也许
transformDataOfObj02.ApplyTo(anotherObject.transform);
- 2 回答
- 0 关注
- 109 浏览
添加回答
举报