Skip to content

Instantly share code, notes, and snippets.

@GhatSmith
Created November 27, 2018 17:45
Show Gist options
  • Save GhatSmith/613b8ba26a38c430f1e8df14fbe320d8 to your computer and use it in GitHub Desktop.
Save GhatSmith/613b8ba26a38c430f1e8df14fbe320d8 to your computer and use it in GitHub Desktop.
Little script to open a locked inspector window as popup in Unity
using UnityEditor;
using UnityEngine;
using System.Reflection;
namespace Framework.Core.EditorExtension
{
public class OpenAdditionalLockedInpsector : MonoBehaviour
{
private static EditorWindow lockedInspectorWindow = null;
[MenuItem("GameObject/Tools/Locked Inspector &%l", false, 199)]
static void DisplayLockedInspector()
{
if (lockedInspectorWindow != null)
{
// Close locked inspector window
lockedInspectorWindow.Close();
DestroyImmediate(lockedInspectorWindow);
lockedInspectorWindow = null;
}
else
{
// Create new inspector window
lockedInspectorWindow = ScriptableObject.CreateInstance(GetInspectorWindowType()) as EditorWindow;
lockedInspectorWindow.Show();
// Lock new inspector window
GetInspectorWindowType().GetMethod("FlipLocked", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).Invoke(lockedInspectorWindow, null);
}
}
private static System.Type GetInspectorWindowType()
{
return typeof(UnityEditor.Editor).Assembly.GetType("UnityEditor.InspectorWindow");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment