Exception when opening explorer

Issue #226 wontfix
William Besnard created an issue

That's a pretty specific issue, but I thought I'd report it anyway :)

When opening a folder in explorer on Windows 10 through a button, few Exceptions are raised:

InvalidOperationException: Operation is not valid due to the current state of the object System.Collections.Generic.Stack1[System.Int32].Pop () Sirenix.OdinInspector.Editor.InspectorProperty.PopDraw () (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/Persistent/GlobalPersistentContext.cs:35) Sirenix.OdinInspector.Editor.InspectorUtilities.DrawProperty (Sirenix.OdinInspector.Editor.InspectorProperty property, UnityEngine.GUIContent label) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:601) Sirenix.OdinInspector.Editor.InspectorUtilities.DrawProperty (Sirenix.OdinInspector.Editor.InspectorProperty property) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:527) Sirenix.OdinInspector.Editor.Drawers.BoxGroupAttributeDrawer.DrawPropertyGroupLayout (Sirenix.OdinInspector.Editor.InspectorProperty property, Sirenix.OdinInspector.BoxGroupAttribute attribute, UnityEngine.GUIContent label) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/AssetListAttributeDrawer.cs:399) Sirenix.OdinInspector.Editor.OdinGroupDrawer1[TGroupAttribute].DrawPropertyImplementation (Sirenix.OdinInspector.Editor.InspectorProperty property, UnityEngine.GUIContent label) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Context/PropertyContextContainer.cs:273) Sirenix.OdinInspector.Editor.OdinDrawer.DrawProperty (Sirenix.OdinInspector.Editor.InspectorProperty property, UnityEngine.GUIContent label) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:283) Sirenix.OdinInspector.Editor.InspectorUtilities.DrawProperty (Sirenix.OdinInspector.Editor.InspectorProperty property, UnityEngine.GUIContent label) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:601) Rethrow as OdinPropertyException: This error occurred while being drawn by Odin. Odin Property Path: #Save Directory Odin Drawer Chain: BoxGroupAttributeDrawer. UnityEngine.Debug:LogException(Exception) Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty, GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:601) Sirenix.OdinInspector.Editor.InspectorUtilities:DrawProperty(InspectorProperty) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:527) Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:520) Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/Persistent/PersistentContextCache.cs:182) Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/DrawerPriority.cs:380) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

The following exception was thrown when drawing property #Save Directory. UnityEngine.Debug:Log(Object) Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:522) Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/Persistent/PersistentContextCache.cs:182) Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/DrawerPriority.cs:380) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

InvalidOperationException: Operation is not valid due to the current state of the object System.Collections.Generic.Stack`1[System.Int32].Pop () Sirenix.OdinInspector.Editor.InspectorProperty.PopDraw () (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/Persistent/GlobalPersistentContext.cs:35) Sirenix.OdinInspector.Editor.InspectorUtilities.DrawProperty (Sirenix.OdinInspector.Editor.InspectorProperty property, UnityEngine.GUIContent label) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:601) Sirenix.OdinInspector.Editor.InspectorUtilities.DrawProperty (Sirenix.OdinInspector.Editor.InspectorProperty property) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:527) Sirenix.OdinInspector.Editor.InspectorUtilities.DrawPropertiesInTree (Sirenix.OdinInspector.Editor.PropertyTree tree) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:520) UnityEngine.Debug:LogException(Exception) Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/InspectorPropertyInfo.cs:522) Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/Persistent/PersistentContextCache.cs:182) Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/DrawerPriority.cs:380) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

NullReferenceException: Object reference not set to an instance of an object UnityEngine.GUILayoutUtility.BeginLayoutGroup (UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options, System.Type layoutType) (at C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:296) UnityEditor.EditorGUILayout.BeginHorizontal (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7696) UnityEditor.EditorGUILayout.BeginHorizontal (UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7676) UnityEditor.InspectorWindow.AddComponentButton (UnityEditor.Editor[] editors) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1396) UnityEditor.InspectorWindow.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:389) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:285) UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:278) UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:245)

here's the piece of code that create the exception:

#if UNITY_EDITOR

    [BoxGroup("Save Directory"), MultiLineProperty]
    public string FullSaveDirectory { get { return Application.persistentDataPath + SaveDirectory; } }

    [ShowInInspector,BoxGroup("Save Directory")]
    public bool IsDirectoryCreated { get { return Directory.Exists(FullSaveDirectory); } }

    [BoxGroup("Save Directory"), Button(ButtonSizes.Medium)]
    public void OpenSaveDirectory()
    {
        if (IsDirectoryCreated)
            Process.Start(@Application.persistentDataPath + SaveDirectory);
        else
        {
            Process.Start(@Application.persistentDataPath);
        }
    }
#endif

Comments (3)

  1. mSkull001

    This could be hard to do anything about, as it seems to be caused by the GUI drawing chain ending when you start the process for some reason. Evt because Unity loses focus?

    You should be able to get rid of the exception by using UnityEditor.EditorApplication.delayCall though:

    [BoxGroup("Save Directory"), Button(ButtonSizes.Medium)]
    public void OpenSaveDirectory()
    {
        if (IsDirectoryCreated)
        {
            UnityEditor.EditorApplication.delayCall += Process.Start(@Application.persistentDataPath + SaveDirectory);
        }
        else
        {
            UnityEditor.EditorApplication.delayCall += Process.Start(@Application.persistentDataPath);
        }
    }
    
  2. Dominic Antonelli

    I get this same error upon double-clicking a Sprite object inside of an OdinMenuEditorWindow. It appears to be the same issue because when I do double-click this Sprite object, it opens the png file in a new window in the Windows Photos app. In this particular instance, I can't really use the workaround you mention since I don't control any of the code that opens the file.

    On the other hand, the error doesn't really seem to break anything, so I'm not exactly worried about it. I just came across this ticket when googling the error.

  3. Log in to comment