0
\$\begingroup\$

I am using Unity 2018.4.11f1 LTS. I have a script with a public List<GameObject> field.

In the property inspector, Unity provides a UI to this field where you specify the size of the list and then assign elements:

public List<GameObject> receivers;

enter image description here

My question is: Is there a way (perhaps a different field type) to have Unity provide an editor UI that consists of a +/- button where you can add and remove elements, rather than a list-size-based UI?

Something more along the lines of e.g. what it gives you for UnityEvents:

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Before anybody asks: I don't have any particular functional reason for wanting this UI, I just like it better. \$\endgroup\$
    – Jason C
    Commented Oct 27, 2019 at 22:55

1 Answer 1

2
\$\begingroup\$

you can use NaughtyAttributes

NaughtyAttributes is an extension for the Unity Inspector.

It expands the range of attributes that Unity provides so that you can create powerful inspectors without the need of custom editors or property drawers. It also provides attributes that can be applied to non-serialized fields or functions.

It is implemented by replacing the default Unity Inspector. This means that if you have any custom editors, NaughtyAttributes will not work with them. All of your custom editors and property drawers are not affected in any way.

ReorderableList

Provides array type fields with an interface for easy reordering of elements.

enter image description here

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ It's perfect, thank you. And so naughty. My app feels devilishly NSFW now. \$\endgroup\$
    – Jason C
    Commented Oct 28, 2019 at 13:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .