UnityEngine.UI.Graphic.Raycast C# (CSharp) Method

Raycast() public method

public Raycast ( System.Vector2 sp, Camera eventCamera ) : bool
sp System.Vector2
eventCamera Camera
return bool
        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;
        }

Usage Example

Beispiel #1
0
 static public int Raycast(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.UI.Graphic self = (UnityEngine.UI.Graphic)checkSelf(l);
         UnityEngine.Vector2    a1;
         checkType(l, 2, out a1);
         UnityEngine.Camera a2;
         checkType(l, 3, out a2);
         var ret = self.Raycast(a1, a2);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
All Usage Examples Of UnityEngine.UI.Graphic::Raycast