- Home /
Question by
delstrega · Jul 11, 2012 at 05:51 PM ·
editorinspectorlockcustom inspector
Set inspector lock by code?
Hi!
The easiest way to accomplish what I need for my current project would be locking and unlocking the inspector. But since it's not really that great to click the "lock icon" that often I would like to do it from within my editor script.
Is it possible to lock / unlock the inspector by code?
Comment
Answer by Raikish · Sep 29, 2019 at 12:09 PM
Hey, I made a small editor script to show an example of how you can do this based in the accepted answer.
public class LockMenu : UnityEditor.Editor
{
[MenuItem("Tools/Toggle Inspector Lock %l")] // Ctrl + L
public static void ToggleInspectorLock()
{
ActiveEditorTracker.sharedTracker.isLocked = !ActiveEditorTracker.sharedTracker.isLocked;
ActiveEditorTracker.sharedTracker.ForceRebuild();
}
}