Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug My inspector keeps getting locked

Discussion in 'Editor & General Support' started by illinar, Sep 1, 2020.

  1. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    857
    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.
     
    Last edited: Sep 1, 2020
    Airmouse, CloudyVR and jcuffedsays like this.
  2. jcuffedsays

    jcuffedsays

    Joined:
    Jan 18, 2019
    Posts:
    3
    I am also getting the exact same bug on 2019.3.8f1. There isn't a sane workaround it seems.
     
  3. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    709
    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/ins...ing-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.
     
    Last edited: Oct 3, 2020
  4. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    709
    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 !!
     
    Last edited: Sep 8, 2020
  5. jcuffedsays

    jcuffedsays

    Joined:
    Jan 18, 2019
    Posts:
    3
    No, there literally isn't. I guess Unity just isn't interested in fixing this workflow breaking bug. /shrug
     
    Airmouse and CloudyVR like this.
  6. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    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).
     
    CloudyVR likes this.
  7. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    709
    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,
     
    Last edited: Dec 28, 2020
  8. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    709
    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:
    Code (CSharp):
    1. /// <summary>
    2. /// This toggles the inspector mode whenever a new scene object is selected.
    3. /// This can be used to partially restore inspector windows to a working state after
    4. /// random Unity editor glitching has occured and all inspector windows are unresponsive.
    5. /// It's important that FixDeadInspector window be visible somewhere in the Editor for this to work!
    6. /// </summary>
    7. #if UNITY_EDITOR
    8. using System;
    9. using System.Reflection;
    10. using UnityEngine;
    11. using UnityEditor;
    12. public class FixDeadInspectors : EditorWindow
    13. {
    14.     [MenuItem("Glitches/Fix Dead Inspectors")]
    15.     static void Init()
    16.     {
    17.         FixDeadInspectors window = (FixDeadInspectors)GetWindow(typeof(FixDeadInspectors));
    18.         window.minSize = Vector2.zero;
    19.         window.Show();
    20.     }
    21.  
    22.     void OnSelectionChange() //whenever a scene object is select refresh the inspector
    23.     {
    24.     EditorWindow[] allWindows = Resources.FindObjectsOfTypeAll<EditorWindow>();
    25.  
    26.     foreach (var targetInspector in allWindows) //for all windows in the editor
    27.         if (targetInspector != null  && targetInspector.GetType().Name == "InspectorWindow") //only for inspector windows
    28.         {
    29.             Type type = Assembly.GetAssembly(typeof(UnityEditor.Editor)).GetType("UnityEditor.InspectorWindow"); //Get the type of the inspector window to find out the variable/method from
    30.             FieldInfo field = type.GetField("m_InspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);    //get the field we want to read, for the type (not our instance)
    31.  
    32.             for (int i = 0; i < 2; i++) //toggle the InspectorMode
    33.             {
    34.                 InspectorMode mode = (InspectorMode)field.GetValue(targetInspector); //read the value for our target inspector
    35.                 mode = (mode == InspectorMode.Normal ? InspectorMode.Debug : InspectorMode.Normal); //toggle the value
    36.                 MethodInfo method = type.GetMethod("SetMode", BindingFlags.NonPublic | BindingFlags.Instance); //Find the method to change the mode for the type
    37.                 method.Invoke(targetInspector, new object[] {mode}); //Call the function on our targetInspector, with the new mode as an object[]
    38.             }
    39.             targetInspector.Repaint(); //refresh inspector
    40.         }
    41.     }
    42. }
    43. #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!
     
    Last edited: Dec 30, 2020
    SaintFlorida and pumpkinszwan like this.
  9. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    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.
     
  10. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    709
    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:
    Code (csharp):
    1. /// <summary>
    2. /// This toggles the inspector mode whenever a new scene object is selected.
    3. /// This can be used to partially restore inspector windows to a working state after
    4. /// random Unity editor glitching has occured and all inspector windows are unresponsive.
    5. /// It's important that FixDeadInspector window be visible somewhere in the Editor for this to work!
    6. /// </summary>
    7. #if UNITY_EDITOR
    8. using System;
    9. using System.Reflection;
    10. using UnityEngine;
    11. using UnityEditor;
    12. public class FixDeadInspectors : EditorWindow
    13. {
    14.     [MenuItem("Glitches/Fix Dead Inspectors")]
    15.     static void Init()
    16.     {
    17.         FixDeadInspectors window = (FixDeadInspectors)GetWindow(typeof(FixDeadInspectors));
    18.         window.minSize = Vector2.zero;
    19.         window.Show();
    20.     }
    21.  
    22.     private int lastComponentCount;
    23.     private GameObject lastActiveGameObject;
    24.     void OnInspectorUpdate() //whenever the user adds or removes a component to the active object
    25.     {
    26.         if (lastActiveGameObject == Selection.activeGameObject)
    27.             if (Selection.activeGameObject != null)
    28.             {
    29.                 var componentCount = Selection.activeGameObject.GetComponents<Component>().Length;
    30.                 if (componentCount != lastComponentCount)
    31.                 {
    32.                     lastComponentCount = componentCount;
    33.                     ToggleInspectorMode();
    34.                 }
    35.             }
    36.     }
    37.  
    38.     void OnSelectionChange() //whenever a scene object is select refresh the inspector
    39.     {
    40.         lastActiveGameObject = Selection.activeGameObject;
    41.         if (lastActiveGameObject == Selection.activeGameObject)
    42.             lastComponentCount = Selection.activeGameObject.GetComponents<Component>().Length;
    43.         ToggleInspectorMode();
    44.     }
    45.  
    46.     void ToggleInspectorMode()
    47.     {
    48.         EditorWindow[] allWindows = Resources.FindObjectsOfTypeAll<EditorWindow>();
    49.         foreach (var targetInspector in allWindows) //for all windows in the editor
    50.             if (targetInspector != null  && targetInspector.GetType().Name == "InspectorWindow") //only for inspector windows
    51.             {
    52.                 Type type = Assembly.GetAssembly(typeof(UnityEditor.Editor)).GetType("UnityEditor.InspectorWindow"); //Get the type of the inspector window to find out the variable/method from
    53.                 FieldInfo field = type.GetField("m_InspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);    //get the field we want to read, for the type (not our instance)
    54.  
    55.                 for (int i = 0; i < 2; i++) //toggle the InspectorMode
    56.                 {
    57.                     InspectorMode mode = (InspectorMode)field.GetValue(targetInspector); //read the value for our target inspector
    58.                     mode = (mode == InspectorMode.Normal ? InspectorMode.Debug : InspectorMode.Normal); //toggle the value
    59.                     MethodInfo method = type.GetMethod("SetMode", BindingFlags.NonPublic | BindingFlags.Instance); //Find the method to change the mode for the type
    60.                     method.Invoke(targetInspector, new object[] {mode}); //Call the function on our targetInspector, with the new mode as an object[]
    61.                 }
    62.                 targetInspector.Repaint(); //refresh inspector
    63.             }
    64.     }
    65. }
    66. #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..
     
    Last edited: Jan 1, 2021
  11. C_Larsson

    C_Larsson

    Joined:
    Jun 27, 2022
    Posts:
    8
    Just adding to the pile of complaints, same bug in 2022.2.3, drives me nuts!