Ejemplo n.º 1
0
        public static GameObject GetUIElementbyRaycast(Point point)
        {
            Point pt = new Point(0, 0);

            if (point.X < 1 && point.X > 0 && point.Y < 1 && point.Y > 0)
            {
                pt = new Point(Screen.width * point.X, Screen.height * (1 - point.Y));
            }
            else if (RuntimePlatform.Android == Application.platform)
            {
                pt = CoordinateTool.ConvertMobile2Unity(point);
            }
            else
            {
                pt = new Point(point.X, Screen.height - point.Y);
            }
            Vector2    vector     = CoordinateTool.ConvertPoint2Vector(pt);
            bool       invalid    = false;
            GameObject gameObject = Raycast(vector, ref invalid);

            return(gameObject);
        }
Ejemplo n.º 2
0
        public static GameObject GetUIElementbyRaycast(Point point)
        {
            if (EventSystem.current == null)
            {
                Logger.d("No Event System");
                return(null);
            }
            Point pt = new Point(0, 0);

            if (point.X > 0 && point.X < 1 && point.Y > 0 && point.Y < 1)   //归一化的坐标
            {
                pt = new Point(Screen.width * point.X, Screen.height * (1 - point.Y));
            }
            else if (RuntimePlatform.Android == Application.platform)
            {//android绝对坐标
                pt = CoordinateTool.ConvertMobile2Unity(point);
            }
            else
            {//一般绝对坐标
                pt = new Point(point.X, (1 - point.Y));
            }

            return(GetUIElementbyRaycastByUnity(pt));
        }