InvalidOperationException when accessing SerializedProperty in CustomPropertyDrawer

Issue #24 resolved
Ivan Wang created an issue

I have a custom property drawer for a custom System.Serializable struct IntVector2.



However, when rendering the editor for a class with the field IntVector2, the following error occurs:

From my best guess, it looks like the SerializedProperty has already been cycled through (via Next) and can't be used in the OnGUI method anymore.

In case this isn't enough to reproduce the bug: the class containing IntVector2 (call it A) extends an abstract class B, which is serialized in a list as

public List<B> testList;

Error occurs in Unity v5.5.0f3.

Comments (4)

  1. Tor Esa Vestergaard

    I've been unable to reproduce this bug on the latest patch (, and changes were introduced in that may very well haved fixed this issue. Could you please try upgrading from your current version ( to or, and tell me if the error persists?

  2. Bjarke Elias

    Also just a quick tip in case you didn't know. Writing drawers using Odin makes your life a little easier 😋 No need to return the height of a property, you can use GUILayout, and you also don't need to think too much about undo, Odin also takes care of that. And multi-selection also works in many simple cases out of the box using the entry.SmartValue

    Here is an example of your IntVector2 drawer using Odin.

    public class IntVector2Drawer : OdinValueDrawer<IntVector2>
        protected override void DrawPropertyLayout(IPropertyValueEntry<IntVector2> entry, GUIContent label, params GUILayoutOption[] options)
            Vector2 v2 = SirenixEditorFields.Vector2Field(label, new Vector2(entry.SmartValue.x, entry.SmartValue.y));
            entry.SmartValue = new IntVector2((int)v2.x, (int)v2.y);
  3. Ivan Wang reporter

    Looks like this is fixed in Thanks for the advice in writing drawers in Odin, I've been waiting for the documentation to come out :)


  4. Log in to comment