- Home /
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.
You would have to use C# reflection. It's not a pretty solution and it can easily backfire, but it's the only way as far as I know
Answer by PizzaPie · Aug 16, 2018 at 01:08 PM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172907im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Custom Inspector for ScriptableObject 1 Answer
Organizing Recursive EditorGUI elements 1 Answer
Save ScriptableObject On Unity Application Quit? 1 Answer
Referencing / linking a .asset / .prefab file in another .asset / .prefab file programmatically. 2 Answers
Serialization depth limit 7 exceeded 1 Answer