예제 #1
0
        public virtual bool Raycast(Vector2 sp, Camera eventCamera)
        {
            if (!base.isActiveAndEnabled)
            {
                return(false);
            }
            Transform        transform = base.transform;
            List <Component> list      = ListPool <Component> .Get();

            bool flag  = false;
            bool flag2 = true;

            while (transform != null)
            {
                transform.GetComponents(list);
                for (int i = 0; i < list.Count; i++)
                {
                    Canvas canvas = list[i] as Canvas;
                    if (canvas != null && canvas.overrideSorting)
                    {
                        flag2 = false;
                    }
                    ICanvasRaycastFilter canvasRaycastFilter = list[i] as ICanvasRaycastFilter;
                    if (canvasRaycastFilter == null)
                    {
                        continue;
                    }
                    bool        flag3       = true;
                    CanvasGroup canvasGroup = list[i] as CanvasGroup;
                    if (canvasGroup != null)
                    {
                        if (!flag && canvasGroup.ignoreParentGroups)
                        {
                            flag  = true;
                            flag3 = canvasRaycastFilter.IsRaycastLocationValid(sp, eventCamera);
                        }
                        else if (!flag)
                        {
                            flag3 = canvasRaycastFilter.IsRaycastLocationValid(sp, eventCamera);
                        }
                    }
                    else
                    {
                        flag3 = canvasRaycastFilter.IsRaycastLocationValid(sp, eventCamera);
                    }
                    if (!flag3)
                    {
                        ListPool <Component> .Release(list);

                        return(false);
                    }
                }
                transform = ((!flag2) ? null : transform.parent);
            }
            ListPool <Component> .Release(list);

            return(true);
        }
예제 #2
0
        /// <summary>
        ///   <para>When a GraphicRaycaster is raycasting into the scene it will first filter the elments using their RectTransform rect and then it will use this function to determine the elements hit mby the raycast.</para>
        /// </summary>
        /// <param name="sp">Screen point.</param>
        /// <param name="eventCamera">Camera.</param>
        /// <returns>
        ///   <para>True if the provided point is a valid location for GraphicRaycaster raycasts.</para>
        /// </returns>
        public virtual bool Raycast(Vector2 sp, Camera eventCamera)
        {
            if (!this.isActiveAndEnabled)
            {
                return(false);
            }
            Transform        transform     = this.transform;
            List <Component> componentList = ListPool <Component> .Get();

            bool flag1 = false;
            bool flag2 = true;

            for (; (UnityEngine.Object)transform != (UnityEngine.Object)null; transform = !flag2 ? (Transform)null : transform.parent)
            {
                transform.GetComponents <Component>(componentList);
                for (int index = 0; index < componentList.Count; ++index)
                {
                    Canvas canvas = componentList[index] as Canvas;
                    if ((UnityEngine.Object)canvas != (UnityEngine.Object)null && canvas.overrideSorting)
                    {
                        flag2 = false;
                    }
                    ICanvasRaycastFilter canvasRaycastFilter = componentList[index] as ICanvasRaycastFilter;
                    if (canvasRaycastFilter != null)
                    {
                        bool        flag3       = true;
                        CanvasGroup canvasGroup = componentList[index] as CanvasGroup;
                        if ((UnityEngine.Object)canvasGroup != (UnityEngine.Object)null)
                        {
                            if (!flag1 && canvasGroup.ignoreParentGroups)
                            {
                                flag1 = true;
                                flag3 = canvasRaycastFilter.IsRaycastLocationValid(sp, eventCamera);
                            }
                            else if (!flag1)
                            {
                                flag3 = canvasRaycastFilter.IsRaycastLocationValid(sp, eventCamera);
                            }
                        }
                        else
                        {
                            flag3 = canvasRaycastFilter.IsRaycastLocationValid(sp, eventCamera);
                        }
                        if (!flag3)
                        {
                            ListPool <Component> .Release(componentList);

                            return(false);
                        }
                    }
                }
            }
            ListPool <Component> .Release(componentList);

            return(true);
        }
예제 #3
0
        public virtual bool Raycast(Vector2 sp, Camera eventCamera)
        {
            if (!base.isActiveAndEnabled)
            {
                return(false);
            }
            Transform        parent  = base.transform;
            List <Component> results = ListPool <Component> .Get();

            bool flag = false;

            while (parent != null)
            {
                parent.GetComponents <Component>(results);
                for (int i = 0; i < results.Count; i++)
                {
                    ICanvasRaycastFilter filter = results[i] as ICanvasRaycastFilter;
                    if (filter != null)
                    {
                        bool        flag2 = true;
                        CanvasGroup group = results[i] as CanvasGroup;
                        if (group != null)
                        {
                            if (!flag && group.ignoreParentGroups)
                            {
                                flag  = true;
                                flag2 = filter.IsRaycastLocationValid(sp, eventCamera);
                            }
                            else if (!flag)
                            {
                                flag2 = filter.IsRaycastLocationValid(sp, eventCamera);
                            }
                        }
                        else
                        {
                            flag2 = filter.IsRaycastLocationValid(sp, eventCamera);
                        }
                        if (!flag2)
                        {
                            ListPool <Component> .Release(results);

                            return(false);
                        }
                    }
                }
                parent = parent.parent;
            }
            ListPool <Component> .Release(results);

            return(true);
        }
    public static int IsRaycastLocationValid(IntPtr l)
    {
        int result;

        try
        {
            ICanvasRaycastFilter canvasRaycastFilter = (ICanvasRaycastFilter)LuaObject.checkSelf(l);
            Vector2 sp;
            LuaObject.checkType(l, 2, out sp);
            Camera eventCamera;
            LuaObject.checkType <Camera>(l, 3, out eventCamera);
            bool b = canvasRaycastFilter.IsRaycastLocationValid(sp, eventCamera);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, b);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }