UnityEditor.SceneViewPicking.GetAllOverlapping C# (CSharp) Method

GetAllOverlapping() private static method

private static GetAllOverlapping ( Vector2 position ) : List
position Vector2
return List
        private static List<GameObject> GetAllOverlapping(Vector2 position)
        {
            List<GameObject> source = new List<GameObject>();
            while (true)
            {
                GameObject item = HandleUtility.PickGameObject(position, false, source.ToArray());
                if ((source.Count > 0) && (item == source.Last<GameObject>()))
                {
                    Debug.LogError("GetAllOverlapping failed, could not ignore game object '" + item.name + "' when picking");
                    return source;
                }
                if (item == null)
                {
                    return source;
                }
                source.Add(item);
            }
        }

Usage Example

        public static GameObject PickGameObject(Vector2 mousePosition)
        {
            SceneViewPicking.s_RetainHashes = true;
            IEnumerator <GameObject> enumerator = SceneViewPicking.GetAllOverlapping(mousePosition).GetEnumerator();
            GameObject result;

            if (!enumerator.MoveNext())
            {
                result = null;
            }
            else
            {
                GameObject current     = enumerator.Current;
                GameObject gameObject  = HandleUtility.FindSelectionBase(current);
                GameObject gameObject2 = (!(gameObject == null)) ? gameObject : current;
                int        hashCode    = current.GetHashCode();
                int        num         = hashCode;
                if (Selection.activeGameObject == null)
                {
                    SceneViewPicking.s_PreviousTopmostHash = hashCode;
                    SceneViewPicking.s_PreviousPrefixHash  = num;
                    result = gameObject2;
                }
                else if (hashCode != SceneViewPicking.s_PreviousTopmostHash)
                {
                    SceneViewPicking.s_PreviousTopmostHash = hashCode;
                    SceneViewPicking.s_PreviousPrefixHash  = num;
                    result = ((!(Selection.activeGameObject == gameObject)) ? gameObject2 : current);
                }
                else
                {
                    SceneViewPicking.s_PreviousTopmostHash = hashCode;
                    if (Selection.activeGameObject == gameObject)
                    {
                        if (num == SceneViewPicking.s_PreviousPrefixHash)
                        {
                            result = current;
                        }
                        else
                        {
                            SceneViewPicking.s_PreviousPrefixHash = num;
                            result = gameObject;
                        }
                    }
                    else
                    {
                        GameObject x = HandleUtility.PickGameObject(mousePosition, false, null, new GameObject[]
                        {
                            Selection.activeGameObject
                        });
                        if (x == Selection.activeGameObject)
                        {
                            while (enumerator.Current != Selection.activeGameObject)
                            {
                                if (!enumerator.MoveNext())
                                {
                                    SceneViewPicking.s_PreviousPrefixHash = hashCode;
                                    result = gameObject2;
                                    return(result);
                                }
                                SceneViewPicking.UpdateHash(ref num, enumerator.Current);
                            }
                        }
                        if (num != SceneViewPicking.s_PreviousPrefixHash)
                        {
                            SceneViewPicking.s_PreviousPrefixHash = hashCode;
                            result = gameObject2;
                        }
                        else if (!enumerator.MoveNext())
                        {
                            SceneViewPicking.s_PreviousPrefixHash = hashCode;
                            result = gameObject2;
                        }
                        else
                        {
                            SceneViewPicking.UpdateHash(ref num, enumerator.Current);
                            if (enumerator.Current == gameObject)
                            {
                                if (!enumerator.MoveNext())
                                {
                                    SceneViewPicking.s_PreviousPrefixHash = hashCode;
                                    result = gameObject2;
                                    return(result);
                                }
                                SceneViewPicking.UpdateHash(ref num, enumerator.Current);
                            }
                            SceneViewPicking.s_PreviousPrefixHash = num;
                            result = enumerator.Current;
                        }
                    }
                }
            }
            return(result);
        }
All Usage Examples Of UnityEditor.SceneViewPicking::GetAllOverlapping