Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentRect"></param>
        /// <param name="localPoint"></param>
        /// <returns></returns>
        virtual public bool HitTest(Rect contentRect, Vector2 localPoint)
        {
            RaycastHit hit;

            if (!HitTestContext.GetRaycastHitFromCache(HitTestContext.camera, out hit))
            {
                return(false);
            }

            if (hit.collider != collider)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="container"></param>
        /// <param name="localPoint"></param>
        /// <returns></returns>
        virtual public bool HitTest(Container container, ref Vector2 localPoint)
        {
            Camera     camera = container.GetRenderCamera();
            RaycastHit hit;

            if (!HitTestContext.GetRaycastHitFromCache(camera, out hit))
            {
                return(false);
            }

            if (hit.collider != collider)
            {
                return(false);
            }

            localPoint = container.GetHitTestLocalPoint();
            return(true);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentRect"></param>
        /// <param name="localPoint"></param>
        /// <returns></returns>
        override public bool HitTest(Rect contentRect, Vector2 localPoint)
        {
            RaycastHit hit;

            if (!HitTestContext.GetRaycastHitFromCache(HitTestContext.camera, out hit))
            {
                return(false);
            }

            if (hit.collider != collider)
            {
                return(false);
            }

            lastHit = new Vector2(hit.textureCoord.x * contentRect.width, (1 - hit.textureCoord.y) * contentRect.height);
            HitTestContext.direction  = Vector3.back;
            HitTestContext.worldPoint = StageCamera.main.ScreenToWorldPoint(new Vector2(lastHit.x, Screen.height - lastHit.y));

            return(true);
        }
        override public bool HitTest(Container container, ref Vector2 localPoint)
        {
            Camera camera = container.GetRenderCamera();

            RaycastHit hit;

            if (!HitTestContext.GetRaycastHitFromCache(camera, out hit))
            {
                return(false);
            }

            if (hit.collider != collider)
            {
                return(false);
            }

            localPoint = new Vector2(hit.textureCoord.x * this.width, (1 - hit.textureCoord.y) * this.height);
            HitTestContext.direction  = Vector3.back;
            HitTestContext.worldPoint = StageCamera.main.ScreenToWorldPoint(new Vector2(localPoint.x, Screen.height - localPoint.y));

            return(true);
        }