My inspector keeps getting locked

It's happening since 2018 or 2019 version, I don't remember but for quite a while. The only response I got from unity team was "try a different layout" as if that is a magic solution no that untraceable bug.

It didn't help. I've had a little different layouts, but generally it's like this, and I have to often restart unity because it's the only way to get inspector working properly again.

So the issue: the inspector often behaves as if it is locked but it is not, and nothing can get it out of that state.

3 Likes

I am also getting the exact same bug on 2019.3.8f1. There isn't a sane workaround it seems.

You are not alone, this has been happening to us for nearly a year (and no one at Unity has responded to any pleas for help):
https://forum.unity.com/threads/inspector-tab-randomly-glitching-must-restart-unity-every-5-minutes.820236

The amount of time wasted due to this has been staggering!!! I have never had a worse experience in any IDE.

now with the Unity 2020 major direction change and they have removed support for OpenVR we are never going to be able to upgrade our project - so even if they do get around to finding and fixing the inspector lockup issue, we are probably stuck using the bugged out 2019 Editors.


Is there any workaround? I think my I9 could spare a few cycles - even if it is expensive anything is better than needing to restart Unity every few minutes!!

Any solution? Even god awful ones? Please somebody share !!


No, there literally isn't. I guess Unity just isn't interested in fixing this workflow breaking bug. /shrug

2 Likes

When this happens to me, entering play mode and then exiting play mode will unlock the Inspector. However, it usually locks again shortly after, and restarting Unity is a more reliable fix.

It's such an annoying bug, and it's been around for several versions (and still exists in 2020.1.6).

1 Like

I can't continue working like this, every five minutes or so I am forced to restart Unity editor !!!!

Has anyone found any way to fix this yet? I think it's been over a year now and this really small annoying and crippling bug that I'm sure is merely a Thread lifecycle thing still exits. But team Unity refuses to fix or even to acknowledge the bug exists - I can confirm that it does (and in every editor from 2019 onward).

How can they expect any large scale projects to be successful when such a crippling handicap exists. This flaky inspector tab behavior has cost me so much time and I am a sole developer, but needing to recover my projects more than 15 times per day. Imagine how much wasted time a team of developers would need having to restart Unity 15 times or more every day for each developer on the project? Team Unity is completely insane to not devote more resources to finding this incredibly small yet total user experience breaking bug.

Fixing this would have been item #1 on my list of todo if I ran the place - because I actually care about the user experience - but obviously team Unity is more interested in whatever else,

I solved it !

This script toggles the 'inspector mode' when new objects are select in the scene. That way it works just like changing the mode to Debug and back again but is fully automated and simulates the effect of completely restoring the Inspector:

/// <summary>
/// This toggles the inspector mode whenever a new scene object is selected.
/// This can be used to partially restore inspector windows to a working state after
/// random Unity editor glitching has occured and all inspector windows are unresponsive.
/// It's important that FixDeadInspector window be visible somewhere in the Editor for this to work!
/// </summary>
#if UNITY_EDITOR
using System;
using System.Reflection;
using UnityEngine;
using UnityEditor;
public class FixDeadInspectors : EditorWindow
{
    [MenuItem("Glitches/Fix Dead Inspectors")]
    static void Init()
    {
        FixDeadInspectors window = (FixDeadInspectors)GetWindow(typeof(FixDeadInspectors));
        window.minSize = Vector2.zero;
        window.Show();
    }

    void OnSelectionChange() //whenever a scene object is select refresh the inspector
    {
    EditorWindow[] allWindows = Resources.FindObjectsOfTypeAll<EditorWindow>();

    foreach (var targetInspector in allWindows) //for all windows in the editor
        if (targetInspector != null  && targetInspector.GetType().Name == "InspectorWindow") //only for inspector windows
        {
            Type type = Assembly.GetAssembly(typeof(UnityEditor.Editor)).GetType("UnityEditor.InspectorWindow"); //Get the type of the inspector window to find out the variable/method from
            FieldInfo field = type.GetField("m_InspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);    //get the field we want to read, for the type (not our instance)

            for (int i = 0; i < 2; i++) //toggle the InspectorMode
            { 
                InspectorMode mode = (InspectorMode)field.GetValue(targetInspector); //read the value for our target inspector
                mode = (mode == InspectorMode.Normal ? InspectorMode.Debug : InspectorMode.Normal); //toggle the value
                MethodInfo method = type.GetMethod("SetMode", BindingFlags.NonPublic | BindingFlags.Instance); //Find the method to change the mode for the type
                method.Invoke(targetInspector, new object[] {mode}); //Call the function on our targetInspector, with the new mode as an object[]
            }
            targetInspector.Repaint(); //refresh inspector
        }
    }
}
#endif

I developed this script in roughly 20 minutes - after more than 80 hours of lost time during the past year due to this Unity glitch..

If this solution fixes the inspector then please give this post a like!

2 Likes

Thanks for this! I am testing it now. With an unpredictable bug like this it's impossible to say right away if this script fixes it, but I'll be sure to return here and report how it goes.


Unity editor bugs out every ~5 minutes for me so I've had plenty of opportunity to test this script.

Here's an updated version to include refreshing the dead inspectors whenever components are added and removed:

/// <summary>
/// This toggles the inspector mode whenever a new scene object is selected.
/// This can be used to partially restore inspector windows to a working state after
/// random Unity editor glitching has occured and all inspector windows are unresponsive.
/// It's important that FixDeadInspector window be visible somewhere in the Editor for this to work!
/// </summary>
#if UNITY_EDITOR
using System;
using System.Reflection;
using UnityEngine;
using UnityEditor;
public class FixDeadInspectors : EditorWindow
{
    [MenuItem("Glitches/Fix Dead Inspectors")]
    static void Init()
    {
        FixDeadInspectors window = (FixDeadInspectors)GetWindow(typeof(FixDeadInspectors));
        window.minSize = Vector2.zero;
        window.Show();
    }

    private int lastComponentCount;
    private GameObject lastActiveGameObject;
    void OnInspectorUpdate() //whenever the user adds or removes a component to the active object
    {
        if (lastActiveGameObject == Selection.activeGameObject)
            if (Selection.activeGameObject != null)
            {
                var componentCount = Selection.activeGameObject.GetComponents<Component>().Length;
                if (componentCount != lastComponentCount)
                {
                    lastComponentCount = componentCount;
                    ToggleInspectorMode();
                }
            }
    }

    void OnSelectionChange() //whenever a scene object is select refresh the inspector
    {
        lastActiveGameObject = Selection.activeGameObject;
        if (lastActiveGameObject == Selection.activeGameObject)
            lastComponentCount = Selection.activeGameObject.GetComponents<Component>().Length;
        ToggleInspectorMode();
    }

    void ToggleInspectorMode()
    {
        EditorWindow[] allWindows = Resources.FindObjectsOfTypeAll<EditorWindow>();
        foreach (var targetInspector in allWindows) //for all windows in the editor
            if (targetInspector != null  && targetInspector.GetType().Name == "InspectorWindow") //only for inspector windows
            {
                Type type = Assembly.GetAssembly(typeof(UnityEditor.Editor)).GetType("UnityEditor.InspectorWindow"); //Get the type of the inspector window to find out the variable/method from
                FieldInfo field = type.GetField("m_InspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);    //get the field we want to read, for the type (not our instance)

                for (int i = 0; i < 2; i++) //toggle the InspectorMode
                {
                    InspectorMode mode = (InspectorMode)field.GetValue(targetInspector); //read the value for our target inspector
                    mode = (mode == InspectorMode.Normal ? InspectorMode.Debug : InspectorMode.Normal); //toggle the value
                    MethodInfo method = type.GetMethod("SetMode", BindingFlags.NonPublic | BindingFlags.Instance); //Find the method to change the mode for the type
                    method.Invoke(targetInspector, new object[] {mode}); //Call the function on our targetInspector, with the new mode as an object[]
                }
                targetInspector.Repaint(); //refresh inspector
            }
    }
}
#endif

Still I really wish that Unity editor engineers were not so super lazy and would actually fix this bug proper. But if they are just too lazy and don't feel like fixing their broken editor then at least I can rely on this script to allow me to continue using the editor and developing without being interrupted ever few minutes - and I can totally imagine that it's bugs like this that gives Unity such a horrible reputation..

Just adding to the pile of complaints, same bug in 2022.2.3, drives me nuts!