Can't edit enum arrays in inspector with .NET 4.x

Issue #352 resolved
Anonymous created an issue

1. I use .NET 4.x in my project. I created an enum, then an enum array, and set in public to see it in the inspector. The array is uneditable, every action creates an error in the console (see at the end of post).

2. - Create a new project - Create an enum array, like this one, and put it on a GameObject:

using UnityEngine;

public class EnumArrayTest : MonoBehaviour
{
    public enum GermanicGod { Odin, Thor, Nerthus, Veleda, Tuisto, Mannus }
    public GermanicGod[] gods;
}
  • Play with it a bit, it works! Enums appear correctly.
  • Go to Edit > Project Settings > Player > Other Settings
  • Set Scripting Runtime Version to ".NET 4.x equivalent"
  • Check your object, the enum values have been replaced by their integer representation (see attached screenshot)
  • Try to add new entries, or change the order, it creates this error:

ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array. (wrapper stelemref) System.Object.virt_stelemref_sealed_class(intptr,object) Sirenix.OdinInspector.Editor.PropertyValueEntry`1[TValue].Sirenix.OdinInspector.Editor.IValueEntryActualValueSetter.SetActualValue (System.Int32 index, System.Object value) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/QuaternionDrawer.cs:89) Sirenix.OdinInspector.Editor.PropertyListValueEntryChanger.SetAllTreeActualValueReferences (System.Int32 index, System.Object value, System.Object newValue) (at <16b17155958448d5bd78b565329b0e7d>:0) Sirenix.OdinInspector.Editor.PropertyStrongListValueEntryChanger`2[TList,TElement].AddListElementImplementation (System.Object[] values) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/FixUnityNullDrawer.cs:38) Sirenix.OdinInspector.Editor.PropertyListValueEntryChanger.ApplyChanges () (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/RangeAttributeDrawer.cs:75) Sirenix.OdinInspector.Editor.PropertyValueEntry`2[TParent,TValue].ApplyChanges () (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/TypeDrawer.cs:25) Sirenix.OdinInspector.Editor.PropertyTree.ApplyChanges () (at <16b17155958448d5bd78b565329b0e7d>:0) Sirenix.OdinInspector.Editor.InspectorUtilities.EndDrawPropertyTree (Sirenix.OdinInspector.Editor.PropertyTree tree) (at <16b17155958448d5bd78b565329b0e7d>:0) Sirenix.OdinInspector.Editor.PropertyTree.Draw (System.Boolean applyUndo) (at <16b17155958448d5bd78b565329b0e7d>:0) Sirenix.OdinInspector.Editor.OdinEditor.DrawTree () (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Children/PropertyValueCollection.cs:541) Sirenix.OdinInspector.Editor.OdinEditor.DrawOdinInspector () (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Children/PropertyValueCollection.cs:533) Sirenix.OdinInspector.Editor.OdinEditor.OnInspectorGUI () (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Children/PropertyValueCollection.cs:516) UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, System.Int32 editorIndex, System.Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1295) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

  1. Screenshot attached
  2. I'm using Unity 2018.1.1f1 64bits
  3. I'm using Odin 1.0.6.8
  4. I'm not in Editor only mode
  5. Windows 10

Note: I put this in Critical priority because I simply can't use enum arrays anymore.

Comments (2)

  1. Log in to comment