Skip to content

Instantly share code, notes, and snippets.

@shadesbelow
Created August 11, 2018 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadesbelow/9c358e04b601323ce360d3d505fa7bc4 to your computer and use it in GitHub Desktop.
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)
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