-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathOpenLockedInspector.cs
37 lines (32 loc) · 1.07 KB
/
OpenLockedInspector.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public static class OpenLockedInspector
{
#if UNITY_EDITOR
[MenuItem("GameObject/Open Locked Inspector", false, 49)]
public static void DoOpenLockedInspector()
{
var InspectorType = typeof(Editor).Assembly.GetType("UnityEditor.InspectorWindow");
//var Inspector = EditorWindow.GetWindow(InspectorType) as EditorWindow;
var NewInspector = EditorWindow.CreateInstance (InspectorType) as EditorWindow;
NewInspector.Show ();
// todo: explicitly set object
// try and lock it
// https://github.com/MattRix/UnityDecompiled/blob/master/UnityEditor/UnityEditor/InspectorWindow.cs
try
{
var IsLockedProp = InspectorType.GetProperty("isLocked", typeof(bool) );
if ( !IsLockedProp.CanWrite )
throw new System.Exception("UnityEditor.InspectorWindow.isLocked cannot be written");
IsLockedProp.SetValue( NewInspector, true, null );
}
catch(System.Exception e) {
Debug.LogError ("Failed to lock new inspector: " + e.Message);
}
}
#endif
}