Can T properties of a List<T> be displayed in the editor ?

Hi,

I have a script with a public List property which contains instances of a custom class that inherit of MonoBehavior.

The List shows up in the inspector and I can set its size as expected. But each element of the list in the inspector expect directly an instance of the custom class whereas I’d like each element to show up in the inspector all the public and SerializeField properties of the custom class in order to set-up values.

Thank you

If your custom class inherits from MonoBehaviour, then you’ll have to use a custom Editor to do this; there’s no way to automatically ‘inline’ one component into another one.

Hi,

I have a script A which inherits from MonoBehavior
I have a Custom Editor for the script A
When I attach the script A to a GameObject the Custom Editor is shown in the inspector as expected.

Now I have a script B which inherits from MonoBehavior
Script B has a public List< A> items
When I attach the script B to a GameObject the List items appears but when I set the size the inspector shows script fields in which I have to drag & drop A script instead of displaying the script A Custom Editor for each element in the items List.

Am’I doing something wrong ?

Thank you

Ok, I got that - I thought by “automatically” you meant by not write a Custom Editor.
My bad.
Thank you.

Well, you could write a custom editor for Script B which used Editor.CreateEditor() to create editor objects for each of the items in your list. Then you’d call OnGUI() on each editor object to have it draw its UI as part of Script B’s editor.