Created
March 28, 2017 21:08
-
-
Save spaceemotion/26c0837188ed62dfc9e381db41810cb5 to your computer and use it in GitHub Desktop.
Displays a window that lists all available EditorWindows inside the Unity Editor.
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 System; | |
using System.Reflection; | |
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
public class EditorWindowFinder : EditorWindow | |
{ | |
[NonSerialized] | |
List<Type> Windows; | |
[NonSerialized] | |
Vector2 scrollPosition; | |
[MenuItem ("Window/EditorWindowFinder")] | |
static void Init () { | |
EditorWindow.GetWindow<EditorWindowFinder> ("Window Finder").Show (); | |
} | |
void OnEnable() { | |
var windowType = typeof(EditorWindow); | |
Windows = new List<Type> (30); | |
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { | |
foreach (var type in assembly.GetTypes ()) { | |
if (windowType != type && windowType.IsAssignableFrom(type)) { | |
Windows.Add (type); | |
} | |
} | |
} | |
Windows.Sort ((a, b) => a.FullName.CompareTo (b.FullName)); | |
} | |
void OnGUI () { | |
using (var scope = new GUILayout.ScrollViewScope(scrollPosition)) { | |
scrollPosition = scope.scrollPosition; | |
foreach (var entry in Windows) { | |
if (GUILayout.Button (entry.FullName)) { | |
EditorWindow.GetWindow(entry); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment