Created
November 27, 2018 17:45
-
-
Save GhatSmith/613b8ba26a38c430f1e8df14fbe320d8 to your computer and use it in GitHub Desktop.
Little script to open a locked inspector window as popup in Unity
This file contains hidden or 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 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