Getting children of SerializedProperty

Hello, I am trying to make a custom editor that edits “DataBase” ScriptableObject that contains an array of “Table” ScriptableObjects that contains some values. My question is how to get and visualise those values from “Table” ScriptableObject considering that “DataBase” is a SerializedObject and “Table” is one of its SerializedProperties.

If there is a better way to organise this system im willing to hear you out about it

ScriptableObjects are assets. They are their own serialization unit. You can pack several ScriptableObjects into a single asset file, but they just live in that file as equals. Your array / list you have in your first ScriptableObject does not “contain” instances of your Table ScriptableObject, but contains serialized references to those other assets. The SerializedObject / SerializedProperty structure essentially ends at that point. However you can create a new SerializedObject for each of the referenced Table instances you get from the SerializedProperties inside the array / List. More specifically objectReferenceValue.

In order to show another ScriptableObject inside the editor of another scriptable object, you have to create the proper Editor for those nested scriptable objects. You can use the static Editor.CreateEditor method or any of the overloads. Of course you have to manually call OnInspectorGUI on them at the place where you need / want it.

While this is possible, for sure, it requires quite a bit of precautions, especially when it comes to nesting / indention, adding and removing elements and so on. People have done that quite a few times in the past. Though it’s always a matter if it’s worth the efford.

Do you ever store a “Table” instance seperately or do you ever directly reference such a Table instance anywhere else in the inspector? If not there’s not really a reason why you would want to make the Table class a ScriptableObject. In that case just make it a normal Serializable class and the content would be stored inside the array of your database object, all in one place, automatically.