Editor refs not being destroyed with InlineEditorAttribute on List<Asset> in OdinMenuEditorWindow

Issue #388 resolved
Romain Pechot created an issue

I'm using Odin 2.0 RC in Unity 2018.2.1f1 on Windows 10 x64

Here's my setup:

A OdinMenuEditorWindow listing all my custom ScriptableObject.

My custom ScriptableObject all have a List<GameObject> with the attribute [InlineEditor(LargePreview)].

Editor Setup

When I switch back and forth between the menu items the contextual Editor of each GameObject of the list are not destroyed (assumption).

After a short time the Editor break and I got two messages:

1 Warning

Attempting to open > 63 preview scenes, this is not supported, ensure you dispose of preview scenes properly
UnityEditor.Editor:DrawPreview(Rect)
Sirenix.OdinInspector.Editor.Drawers.InlineEditorAttributeDrawer`1:DoTheDrawing() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueCollectionAlias.cs:351)
Sirenix.OdinInspector.Editor.Drawers.InlineEditorAttributeDrawer`1:DrawEditor() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueCollectionAlias.cs:348)
Sirenix.OdinInspector.Editor.Drawers.InlineEditorAttributeDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueCollectionAlias.cs:342)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferenceValueConflictDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/ValueDropdownAttributeDrawer.cs:405)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferencePathConflictDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.PropertyContextMenuDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/OnValueChangedAttributeDrawer.cs:67)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:368)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/DelayedAttributeDrawer.cs:76)
Sirenix.OdinInspector.Editor.Drawers.CollectionDrawer`1:DrawItem(InspectorProperty, DragHandle, Int32) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/ColorDrawer.cs:90)
Sirenix.OdinInspector.Editor.Drawers.CollectionDrawer`1:DrawItems() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/ColorDrawer.cs:77)
Sirenix.OdinInspector.Editor.Drawers.CollectionDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.NullableReferenceDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/QuaternionDrawer.cs:63)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferenceValueConflictDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/ValueDropdownAttributeDrawer.cs:405)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferencePathConflictDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.FixUnityNullDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferenceDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/OnValueChangedAttributeDrawer.cs:105)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.PropertyContextMenuDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/OnValueChangedAttributeDrawer.cs:67)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:368)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/DelayedAttributeDrawer.cs:76)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/SerializationInfoMenuItem.cs:27)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/SpaceAttributeDrawer.cs:46)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree()
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector()
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI()
Sirenix.OdinInspector.Editor.OdinEditorWindow:DrawEditor(Int32) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueEntry.cs:51)
Sirenix.OdinInspector.Editor.OdinEditorWindow:DrawEditors() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyListValueEntryChanger.cs:268)
Sirenix.OdinInspector.Editor.OdinEditorWindow:OnGUI()
Sirenix.OdinInspector.Editor.OdinMenuEditorWindow:OnGUI() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/OdinSelectors/OdinSelector.cs:426)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)t32, IntPtr)

And 1 Error:

InvalidOperationException: Preview scene could not be created
UnityEditor.PreviewScene..ctor (System.String sceneName) (at C:/buildslave/unity/build/Editor/Mono/Inspector/PreviewRenderUtility.cs:23)
UnityEditor.PreviewRenderUtility..ctor () (at C:/buildslave/unity/build/Editor/Mono/Inspector/PreviewRenderUtility.cs:102)
UnityEditor.GameObjectInspector+PreviewData..ctor (UnityEngine.Object targetObject) (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:86)
UnityEditor.GameObjectInspector.GetPreviewData () (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:523)
UnityEditor.GameObjectInspector.OnPreviewGUI (Rect r, UnityEngine.GUIStyle background) (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:769)
UnityEditor.Editor.OnInteractivePreviewGUI (Rect r, UnityEngine.GUIStyle background) (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:904)
UnityEditor.ObjectPreview.DrawPreview (IPreviewable defaultPreview, Rect previewArea, UnityEngine.Object[] targets) (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:229)
UnityEditor.Editor.DrawPreview (Rect previewArea) (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:921)
Sirenix.OdinInspector.Editor.Drawers.InlineEditorAttributeDrawer`1[UnityEngine.GameObject].DoTheDrawing () (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueCollectionAlias.cs:351)
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.Drawers.InlineEditorAttributeDrawer`1:DoTheDrawing() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueCollectionAlias.cs:351)
Sirenix.OdinInspector.Editor.Drawers.InlineEditorAttributeDrawer`1:DrawEditor() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueCollectionAlias.cs:348)
Sirenix.OdinInspector.Editor.Drawers.InlineEditorAttributeDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueCollectionAlias.cs:342)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferenceValueConflictDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/ValueDropdownAttributeDrawer.cs:405)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferencePathConflictDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.PropertyContextMenuDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/OnValueChangedAttributeDrawer.cs:67)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:368)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/DelayedAttributeDrawer.cs:76)
Sirenix.OdinInspector.Editor.Drawers.CollectionDrawer`1:DrawItem(InspectorProperty, DragHandle, Int32) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/ColorDrawer.cs:90)
Sirenix.OdinInspector.Editor.Drawers.CollectionDrawer`1:DrawItems() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/ColorDrawer.cs:77)
Sirenix.OdinInspector.Editor.Drawers.CollectionDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.NullableReferenceDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/QuaternionDrawer.cs:63)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferenceValueConflictDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/ValueDropdownAttributeDrawer.cs:405)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferencePathConflictDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.FixUnityNullDrawer`1:DrawPropertyLayout(GUIContent)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.ReferenceDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/OnValueChangedAttributeDrawer.cs:105)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32)
Sirenix.OdinInspector.Editor.Drawers.PropertyContextMenuDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/OnValueChangedAttributeDrawer.cs:67)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:368)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/DelayedAttributeDrawer.cs:76)
Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/SerializationInfoMenuItem.cs:27)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/SpaceAttributeDrawer.cs:46)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree()
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector()
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI()
Sirenix.OdinInspector.Editor.OdinEditorWindow:DrawEditor(Int32) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueEntry.cs:51)
Sirenix.OdinInspector.Editor.OdinEditorWindow:DrawEditors() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyListValueEntryChanger.cs:268)
Sirenix.OdinInspector.Editor.OdinEditorWindow:OnGUI()
Sirenix.OdinInspector.Editor.OdinMenuEditorWindow:OnGUI() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/OdinSelectors/OdinSelector.cs:426)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Comments (9)

  1. Bjarke Elias

    Thanks! I'll look into this.

    Currently, all editors should be destroyed at some point, but it doesn't happen you change item in an OdinMenuEditorWindow, which it definitely should.

    Will have to think about this one a bit, we need a good way of knowing exactly when to destroy old editors.

  2. Romain Pechot reporter

    Going back and forth between items from a OdinMenuTree trigger this Exception (too many preview, ensure to dispose), so my guess was Editors used for the preview aren't correctly destroyed ?

  3. Bjarke Elias

    Thanks a lot for your help!

    OdinPropertyTrees are now disposable and invoked properly throughout Odin. The InlineEditorAttributeDrawer now implements the disposable and ensures all created editors are destroyed instead of only destroying them on selection changed.

  4. Log in to comment