Scriptable Object serialization

I am creating a very basic SO with a single public List inside:

…and I am creating a custom editor script with a reordable list for it. Below is the simplified editor script I am using:

[CustomEditor(typeof(ItemsManager))]
    public class ItemsManagerEditor : UnityEditor.Editor
    {
        private SerializedProperty items;
        private ReorderableList reorderableList;

        private void OnEnable()
        {
            items = serializedObject.FindProperty(nameof(ItemsManager.Items));

            reorderableList = new ReorderableList(serializedObject, items, true, true, true, true)
            {
                onAddCallback = AddItem,
            };
        }
    
        private static void AddItem(ReorderableList list)
        {
            var index = list.serializedProperty.arraySize;
            list.serializedProperty.arraySize++;
            list.index = index;
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            reorderableList.DoLayoutList();
            serializedObject.ApplyModifiedProperties();
        }

}

This is how the SO is visualized in the inspector:

The problem is that Items is not initialized. If I try to click the [+] to add an item it gives me null reference on line 19 in the Editor script for the serializedProperty or the Items list in ItemsManager.

I used same approach in other projects, same unity version but all was working as expected. The following screenshot is of a similar script but different project, where everything works correctly:

The only difference I see is the little “Serializable” info that Rider is showing to the right of the list items. I wonder why the Items from the ItemsManager is not showing as Serializable? Maybe this is the reason it does not get initialized.

Maybe there are some Editor settings regarding serialization? Any help would be appreciated.

ok, I fixed it. The problem was that the class Item was missing [System.Serializable]. I forget about it so frequently… And of course I had to write this extensive description so that I find the problem 30 mins later.

Uhm … why? Unity has this built-in! :wink:

You can drag those ominous burger menu next to each item and drag items around.

Yeah, the custom editor was not actually about the functionality of reordering the items, but to edit how all the other data is displayed in the SO. I am overwriting many callbacks of the reordable list in order to draw a custom Inspector.
Especially when you work with Game Designers who don’t have any programming knowledge but they still need to be able to edit some object’s properties and data in general. You have to make it look good and easy for them to use.