获得物体在屏幕上的localPosition的方法举例
2017-05-02 02:28
225 查看
public static Vector3 ScreenLocalPosition(Transform target, Vector3 pos) { //变换屏幕坐标到世界坐标 if (Get.UiCamera.orthographic) { pos.x = Mathf.Round(pos.x); pos.y = Mathf.Round(pos.y); pos.z = Mathf.Round(pos.z); } pos = Get.UiCamera.ScreenToWorldPoint(pos); if (!Get.UiCamera.orthographic || target.parent == default(Transform)) return pos; //变换父级(ngui)坐标到世界坐标 pos = target.parent.InverseTransformPoint(pos); pos.x = Mathf.RoundToInt(pos.x); pos.y = Mathf.RoundToInt(pos.y); pos.z = Mathf.RoundToInt(pos.z); return pos;
相关文章推荐
- Android获得屏幕分辨率的两种方法
- Android获得手机屏幕尺寸的方法
- Android 获得手机屏幕宽高参数的几种方法
- 安卓获得屏幕高度和宽度的几种方法
- 获得屏幕宽度和高度的方法
- 获得屏幕大小的两种方法:
- android获得屏幕高度和宽度(display中getSize(Point)方法使用)
- 获得屏幕尺寸的几种方法
- [Android]获得Andriod手机屏幕分辨率的两种方法
- Android编程实现获得手机屏幕真实宽高的方法
- android获得当前view在屏幕中坐标的方法
- iOS 获得屏幕正在显示的Controller(自定义的控制器)的实用方法
- 获得屏幕高宽的方法汇总
- Android获得屏幕高度和宽度的两种方法
- Android获得屏幕分辨率的两种方法
- 分享方法:android 获得屏幕状态
- iOS 获得屏幕正在显示的Controller(自定义的控制器)的实用方法
- android获得屏幕高度和宽度四种方法
- Android获得屏幕分辨率的方法
- android获得屏幕高度和宽度的方法