Created
August 11, 2018 14:59
-
-
Save shadesbelow/9c358e04b601323ce360d3d505fa7bc4 to your computer and use it in GitHub Desktop.
Hotkey for toggling inspector lock (hover mouse over inspector then press alt + q)
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 System; | |
using System.Reflection; | |
using UnityEditor; | |
public class InspectorLockToggle | |
{ | |
[MenuItem("Tools/Toggle Lock &q")] | |
static void ToggleInspectorLock() // Inspector must be inspecting something to be locked | |
{ | |
EditorWindow inspectorToBeLocked = EditorWindow.mouseOverWindow; // "EditorWindow.focusedWindow" can be used instead | |
if (inspectorToBeLocked != null && inspectorToBeLocked.GetType().Name == "InspectorWindow") | |
{ | |
Type type = Assembly.GetAssembly(typeof(Editor)).GetType("UnityEditor.InspectorWindow"); | |
PropertyInfo propertyInfo = type.GetProperty("isLocked"); | |
bool value = (bool)propertyInfo.GetValue(inspectorToBeLocked, null); | |
propertyInfo.SetValue(inspectorToBeLocked, !value, null); | |
inspectorToBeLocked.Repaint(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment