UnityEngine.UI.Selectable.FindSelectable C# (CSharp) Method

FindSelectable() public method

public FindSelectable ( System.Vector3 dir ) : Selectable
dir System.Vector3
return Selectable
        public Selectable FindSelectable(Vector3 dir)
        {
            dir = dir.normalized;
            Vector3 vector = (Vector3) (Quaternion.Inverse(base.transform.rotation) * dir);
            Vector3 vector2 = base.transform.TransformPoint(GetPointOnRectEdge(base.transform as RectTransform, vector));
            float negativeInfinity = float.NegativeInfinity;
            Selectable selectable = null;
            for (int i = 0; i < s_List.Count; i++)
            {
                Selectable selectable2 = s_List[i];
                if (((selectable2 != this) && (selectable2 != null)) && (selectable2.IsInteractable() && (selectable2.navigation.mode != Navigation.Mode.None)))
                {
                    RectTransform transform = selectable2.transform as RectTransform;
                    Vector3 position = (transform == null) ? Vector3.zero : ((Vector3) transform.rect.center);
                    Vector3 rhs = selectable2.transform.TransformPoint(position) - vector2;
                    float num3 = Vector3.Dot(dir, rhs);
                    if (num3 > 0f)
                    {
                        float num4 = num3 / rhs.sqrMagnitude;
                        if (num4 > negativeInfinity)
                        {
                            negativeInfinity = num4;
                            selectable = selectable2;
                        }
                    }
                }
            }
            return selectable;
        }

Usage Example

 static public int FindSelectable(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.Selectable self = (UnityEngine.UI.Selectable)checkSelf(l);
         UnityEngine.Vector3       a1;
         checkType(l, 2, out a1);
         var ret = self.FindSelectable(a1);
         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.Selectable::FindSelectable