unity ui坐标系转换
2020-12-13 06:24
标签:mouse 右上角 通过 sep height pix 屏幕 获取 方法 世界坐标: 屏幕坐标: 视口坐标: GUI坐标: unity ui坐标系转换 标签:mouse 右上角 通过 sep height pix 屏幕 获取 方法 原文地址:https://www.cnblogs.com/sweetXiaoma/p/11177520.html
transform.position获取的是世界坐标
单位像素
屏幕左下角(0,0)右上角(Screen.width,Screen.height)
Screen.width = Camera.main.pixelWidth;
Screen.height = Camera.main.pixelHeight;
可通过Input.mousePosition获取屏幕坐标
屏幕左下角(0,0)右上角(1,1)
视口坐标是一个3D坐标,z轴是相对于相机而言。
通过OnGUI()方法绘制UI时使用的坐标。
单位像素
屏幕左上角(0,0) 右下角(Screen.width,Screen.height)