internal static GameObject PickGameObject(Vector2 position, bool selectPrefabRoot, GameObject[] ignore, GameObject[] filter) { int num; GameObject gameObject = HandleUtility.PickGameObjectDelegated(position, ignore, filter, out num); GameObject result; if (gameObject && selectPrefabRoot) { GameObject gameObject2 = HandleUtility.FindSelectionBase(gameObject) ?? gameObject; Transform activeTransform = Selection.activeTransform; GameObject y = (!activeTransform) ? null : (HandleUtility.FindSelectionBase(activeTransform.gameObject) ?? activeTransform.gameObject); if (gameObject2 == y) { result = gameObject; } else { result = gameObject2; } } else { result = gameObject; } return result; }
internal static GameObject PickGameObject(Vector2 position, bool selectPrefabRoot, GameObject[] ignore, GameObject[] filter) { int num; GameObject gameObject = HandleUtility.PickGameObject(position, ignore, filter, out num); if (!gameObject || !selectPrefabRoot) { return(gameObject); } GameObject gameObject2 = HandleUtility.FindSelectionBase(gameObject) ?? gameObject; Transform activeTransform = Selection.activeTransform; GameObject y = (!activeTransform) ? null : (HandleUtility.FindSelectionBase(activeTransform.gameObject) ?? activeTransform.gameObject); if (gameObject2 == y) { return(gameObject); } return(gameObject2); }
internal static GameObject PickGameObject(Vector2 position, bool selectPrefabRoot, GameObject[] ignore, GameObject[] filter) { int materialIndex; GameObject go = HandleUtility.PickGameObject(position, ignore, filter, out materialIndex); if (!(bool)((Object)go) || !selectPrefabRoot) { return(go); } GameObject gameObject1 = HandleUtility.FindSelectionBase(go) ?? go; Transform activeTransform = Selection.activeTransform; GameObject gameObject2 = !(bool)((Object)activeTransform) ? (GameObject)null : HandleUtility.FindSelectionBase(activeTransform.gameObject) ?? activeTransform.gameObject; if ((Object)gameObject1 == (Object)gameObject2) { return(go); } return(gameObject1); }
public static GameObject PickGameObject(Vector2 mousePosition) { List <GameObject> allOverlapping = GetAllOverlapping(mousePosition); if (allOverlapping.Count == 0) { return(null); } GameObject obj2 = HandleUtility.FindSelectionBase(allOverlapping[0]); int index = allOverlapping.IndexOf(Selection.activeGameObject); if ((GetHashForStack(allOverlapping) != s_HashOfPreviousStack) || (Selection.gameObjects.Count <GameObject>() > 1)) { index = -1; } s_HashOfPreviousStack = GetHashForStack(allOverlapping); if (obj2 != null) { if ((obj2 != Selection.activeGameObject) && (index == -1)) { return(obj2); } if ((obj2 == Selection.activeGameObject) && (index != 0)) { return(HandleUtility.PickGameObject(mousePosition, false)); } if (((index + 1) < allOverlapping.Count) && (allOverlapping[index + 1] == obj2)) { index++; } } if ((index + 1) < allOverlapping.Count) { return(allOverlapping[index + 1]); } if (obj2 != null) { return(obj2); } return(HandleUtility.PickGameObject(mousePosition, false)); }
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); }
public static GameObject PickGameObject(Vector2 mousePosition) { s_RetainHashes = true; var enumerator = GetAllOverlapping(mousePosition).GetEnumerator(); if (!enumerator.MoveNext()) { return(null); } var topmost = enumerator.Current; var selectionBase = HandleUtility.FindSelectionBase(topmost); var first = (selectionBase == null ? topmost : selectionBase); int topmostHash = topmost.GetHashCode(); int prefixHash = topmostHash; if (Selection.activeGameObject == null) { // Nothing selected // Return selection base if it exists, otherwise topmost game object s_PreviousTopmostHash = topmostHash; s_PreviousPrefixHash = prefixHash; return(first); } if (topmostHash != s_PreviousTopmostHash) { // Topmost game object changed // Return selection base if exists and is not already selected, otherwise topmost game object s_PreviousTopmostHash = topmostHash; s_PreviousPrefixHash = prefixHash; return(Selection.activeGameObject == selectionBase ? topmost : first); } s_PreviousTopmostHash = topmostHash; // Pick potential selection base before topmost game object if (Selection.activeGameObject == selectionBase) { if (prefixHash == s_PreviousPrefixHash) { return(topmost); } else { s_PreviousPrefixHash = prefixHash; return(selectionBase); } } // Check if active game object will appear in selection stack var picked = HandleUtility.PickGameObject(mousePosition, false, null, new GameObject[] { Selection.activeGameObject }); if (picked == Selection.activeGameObject) { // Advance enumerator to active game object while (enumerator.Current != Selection.activeGameObject) { if (!enumerator.MoveNext()) { s_PreviousPrefixHash = topmostHash; return(first); // Should not occur } UpdateHash(ref prefixHash, enumerator.Current); } } if (prefixHash != s_PreviousPrefixHash) { // Prefix hash changed, start over s_PreviousPrefixHash = topmostHash; return(first); } // Move on to next game object if (!enumerator.MoveNext()) { s_PreviousPrefixHash = topmostHash; return(first); // End reached, start over } UpdateHash(ref prefixHash, enumerator.Current); if (enumerator.Current == selectionBase) { // Skip selection base if (!enumerator.MoveNext()) { s_PreviousPrefixHash = topmostHash; return(first); // End reached, start over } UpdateHash(ref prefixHash, enumerator.Current); } s_PreviousPrefixHash = prefixHash; return(enumerator.Current); }
public static GameObject PickGameObject(Vector2 mousePosition) { SceneViewPicking.s_RetainHashes = true; IEnumerator <GameObject> enumerator = SceneViewPicking.GetAllOverlapping(mousePosition).GetEnumerator(); if (!enumerator.MoveNext()) { return((GameObject)null); } GameObject current = enumerator.Current; GameObject selectionBase = HandleUtility.FindSelectionBase(current); GameObject gameObject = !((UnityEngine.Object)selectionBase == (UnityEngine.Object)null) ? selectionBase : current; int hashCode = current.GetHashCode(); int hash = hashCode; if ((UnityEngine.Object)Selection.activeGameObject == (UnityEngine.Object)null || hashCode != SceneViewPicking.s_PreviousTopmostHash) { SceneViewPicking.s_PreviousTopmostHash = hashCode; SceneViewPicking.s_PreviousPrefixHash = hash; return(gameObject); } SceneViewPicking.s_PreviousTopmostHash = hashCode; if ((UnityEngine.Object)selectionBase != (UnityEngine.Object)null && (UnityEngine.Object)Selection.activeGameObject == (UnityEngine.Object)selectionBase) { if (hash == SceneViewPicking.s_PreviousPrefixHash) { return(current); } SceneViewPicking.s_PreviousPrefixHash = hash; return(selectionBase); } if ((UnityEngine.Object)HandleUtility.PickGameObject(mousePosition, 0 != 0, (GameObject[])null, new GameObject[1] { Selection.activeGameObject }) == (UnityEngine.Object)Selection.activeGameObject) { while ((UnityEngine.Object)enumerator.Current != (UnityEngine.Object)Selection.activeGameObject) { if (!enumerator.MoveNext()) { SceneViewPicking.s_PreviousPrefixHash = hashCode; return(gameObject); } SceneViewPicking.UpdateHash(ref hash, (object)enumerator.Current); } } if (hash != SceneViewPicking.s_PreviousPrefixHash) { SceneViewPicking.s_PreviousPrefixHash = hashCode; return(gameObject); } if (!enumerator.MoveNext()) { SceneViewPicking.s_PreviousPrefixHash = hashCode; return(gameObject); } SceneViewPicking.UpdateHash(ref hash, (object)enumerator.Current); if ((UnityEngine.Object)enumerator.Current == (UnityEngine.Object)selectionBase) { if (!enumerator.MoveNext()) { SceneViewPicking.s_PreviousPrefixHash = hashCode; return(gameObject); } SceneViewPicking.UpdateHash(ref hash, (object)enumerator.Current); } SceneViewPicking.s_PreviousPrefixHash = hash; return(enumerator.Current); }