| 123456789101112131415161718192021222324252627282930313233343536373839404142 | using FairyGUI;using UnityEngine;namespace GFGGame{    public class CommonUtil : SingletonBase<CommonUtil>    {        /// <summary>        /// 检查一个点是否在某物体范围内        /// </summary>        /// <param name="obj"></param>        /// <param name="point"></param>        /// <returns></returns>        public bool CheckPointIsOnComponent(GObject obj, Vector2 point)        {            if (!obj.visible) return false;            Vector2 p = obj.LocalToGlobal(new Vector2(0, 0));            Debug.Log("p:" + p);            Debug.Log("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;        }    }}
 |