using FairyGUI; using UnityEngine; namespace GFGGame { public class CommonUtil : SingletonBase { /// /// 检查一个点是否在某物体范围内 /// /// /// /// public bool CheckPointIsOnComponent(GObject obj, Vector2 point) { if (!obj.visible) return false; Vector2 p = obj.LocalToGlobal(new Vector2(0, 0)); LogUtil.LogEditor("p:" + p); LogUtil.LogEditor("point:" + point); float w = obj.width; float h = obj.height; float x0 = p.x; float y0 = p.y; float x1 = x0 + w; float y1 = y0 + h; if (point.x >= x0 && point.x < x1 && point.y >= y0 && point.y < y1) { return true; } return false; } private Vector2 _moustPoint = new Vector2(); public Vector2 GetMouseV2Point() { ; Vector2 moustPoint = new Vector2(Input.mousePosition.x, UnityEngine.Screen.height - Input.mousePosition.y);// this. _moustPoint.x = Input.mousePosition.x; _moustPoint.y = UnityEngine.Screen.height - Input.mousePosition.y; return _moustPoint; } } }