How can I display the fields of a ScriptableObject in an editor window? - Any SO even if I don't know the fields within.

Hello,

So I want to create an editor window that can display all the fields of any derived type from ScriptableObject? Lets say for instance I do not know any of the fields in the derived type of SO, how would I make the editor window display any SO I throw at it?

Thanks in advance.

The easiest way would be, as long you use Unity’s Serializer, to use SerializedObject class pick up its SerializedProperties (which refer to field don’t let the name fool you) and then display said properties (fields) with the EditorGUILayout.PropertyField or equivalent method from EditorGUI class.

Using reflection is obvisously more powerfull but it will be fairly harder and will require a lot of code to replicate functionality that exists, as long you work with Unity’s Serializer SerializedObjects/ properties is the way to go.

Cheers.