Created
September 2, 2015 09:21
-
-
Save gindemit/e5f16a5e9a48bed3cb25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UnityEditor; | |
using System.Collections.Generic; | |
public class FindObjectsInTheSceneHelper : EditorWindow | |
{ | |
string className = "Rigidbody"; | |
[MenuItem(MenuItemName.SceneTools + "Find Objects In Current Scene", false, MenuItemSorter.SceneToolsFind)] | |
private static void Init() | |
{ | |
FindObjectsInTheSceneHelper window = ScriptableObject.CreateInstance<FindObjectsInTheSceneHelper>(); | |
window.position = new Rect(Screen.width / 2, Screen.height / 2, 250, 50); | |
window.ShowPopup(); | |
} | |
void OnGUI() | |
{ | |
className = EditorGUILayout.TextField("Component:", className); | |
GUILayout.BeginHorizontal(); | |
if (GUILayout.Button("Find")) | |
{ | |
GameObject[] gos = GameObjectUtilsEditor.GetAllObjectsInScene(false); | |
List<Object> objectsToSelect = new List<Object>(); | |
for (int i = 0; i < gos.Length; ++i) | |
{ | |
if (gos[i].GetComponent(className) != null) | |
{ | |
objectsToSelect.Add(gos[i]); | |
} | |
} | |
Selection.objects = objectsToSelect.ToArray(); | |
this.Close(); | |
} | |
if (GUILayout.Button("Close")) | |
{ | |
this.Close(); | |
} | |
GUILayout.EndHorizontal(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment