Complex List in Inspector..

This question is actually Twofold…
I am able to display and/or add a single types in a List in the inspector, By declaring the list as public. For Instance, I have a list of AudioClips, and i can add elements and drag-drop audio clips in there. But I also want to associate a text with it, (for dialogue speak & display). But if i make it a list of a class (with those two elements) it doesn’t show up in the inspector. Is there a way to make it happen in Unity? (I really want the ability to drag-drop audio clips instead of just doing it in the program).

Next is, What about showing dictionaries in the inspector? (With a key in addition…);

Thanks & Regards


Here’s a great tutorial from Jasper Flick, that helped me get my head around custom inspectors.
Which is what you’ll need to create your own list with custom functionality, like having descriptions displayed with each element of your list

If i got you right all you’re missing is the System.Serializable attribute, right?

// C#

public class DialogItem
    public AudioClip audio;
    public TextAsset text;

public class SomeBehaviour : MonoBehaviour
    public List<DialogItem> dialogs;

You said text file so i used a TextAsset here. However if you want to input a string in the inspectorm just change the type to string. If you want a larger text area to input a text, you have to write a custom inspector for your SomeBehaviour class or a property drawer for your DialogItem class.

If you need more information, just ask :wink: