物体对象在屏幕中的坐标及鼠标坐标

public class CubeLogic : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var position = gameObject.transform.position;

            var pos = Camera.main.WorldToScreenPoint(position);

            Debug.Log("** 屏幕宽度:" + Screen.width);
            Debug.Log("** 屏幕高度:" + Screen.height);

            Debug.Log("** 屏幕坐标:" + pos);

            var mousePositon = Input.mousePosition;

            Debug.Log("** 点击坐标:" + mousePositon);

        }

        gameObject.transform.Translate(1 * Time.deltaTime, 0, 0);
    }
}
posted @   暖暖De幸福  阅读(3)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示