Skip to content

Instantly share code, notes, and snippets.

@spaceemotion
Created March 28, 2017 21:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spaceemotion/26c0837188ed62dfc9e381db41810cb5 to your computer and use it in GitHub Desktop.
Save spaceemotion/26c0837188ed62dfc9e381db41810cb5 to your computer and use it in GitHub Desktop.
Displays a window that lists all available EditorWindows inside the Unity Editor.
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