unity 3D获取当前脚本绑定的物体坐标

分类栏目:unity3d教程

77

unity3D获取当前脚本绑定的物体坐标

代码如下

public class location : MonoBehaviour
{
    // Start is called before the first frame update
    public GameObject A;
    
    public Vector3 localPosition;
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
         print("位置坐标" + this.transform.localPosition);

         print("X坐标为:" + this.transform.localPosition.x);

    }
}