I've been working on a ReorderableList, but it's given me quite the headache. I've come to the point where I want to define a "drawElementCallback" -callback, which looks like this:

list.drawElementCallback = (rect, index, active, focused) => {
    EditorGUI.PropertyField(rect, list.serializedProperty.GetArrayElementAtIndex(index), GUIContent.none);

What it's supposed to draw is one Vector3 object from an array of Vector3 objects. I get this property like this: ("property" is a SerializedProperty that contains the property that I need)

SerializedProperty locationsProperty = property.FindPropertyRelative("locations");

The array is declared as follows:

public Vector3[] locations;

Inside a container class that is marked as "Serializable".

The problem I kept getting with different code is that the ReorderableList shows all the Vectors correctly but it doesn't allow me to reorder any of the items, nor delete them (I can add new Vector3 objects and change them as expected).

With this code, I wanted to fix that issue. However, now I keep getting the following error:

"InvalidOperationException: The operation is not possible when moved past all properties (Next returned false)"

I wanted to make a reorderable list because it seemed easy, but I can't figure out the problem and I honestly wish I hadn't started working on it. It's taken up most of the past 3 days.

If anyone knows how to fix this, I would be very grateful.

To clarify, this code shows the array properly:

list.drawElementCallback = (rect, index, active, focused) => {
    SerializedProperty item = locationsProperty.GetArrayElementAtIndex(index);

    item.vector3Value = EditorGUI.Vector3Field(rect, string.Empty, item.vector3Value);

But doesn't allow me to remove or reorder items. I thought I should show the code to demonstrate that there are indeed array items.


1 Answer 1


I couldn't find the right solution at first, so what I did to solve the problem was make two scripts.

The first was the script that previously contained a bunch of properties, including the array that I wanted to show in the editor. (SerializedObject-> SerializedObject-> Array of Vector3 Objects)

The editor script linked to this added a button to add a script as component, which was the script that previously contained the array of Vector3 objects that I wanted to show in the editor. (SerializedObject -> SerializedObject-> Array of Vector3 Objects)

This allowed me to make two seperate editor scripts; One for the parent object, and one for the child object that contained the list of Vector3's that I wanted to serialize. This made it a lot easier to obtain the SerializedProperty that I needed to create the ReorderableList.

I simply copied the following script and changed it to my needs afterwards, and it was fine: http://va.lent.in/unity-make-your-lists-functional-with-reorderablelist/

I tried to make it as clear as possible, feel free to ask me to clear something up if I didn't manage to do so!

I think the problem was that I didn't get how I paths worked in serializedobjects. It would have looked something like this, to get the list of Vector3 objects inside the child object of the parent object: parentobject.array.data[index].childobjectname.array.data[index].vector3arrayname.array.data[index]

Simply put, if you're in a situation where you're working with nested objects make sure you know how relative paths work!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .