Draw List of UnityEvent

Having this in the target:

List<UnityEvent> events;

How do I expose these events in a custom inspector in the same way they are exposed when UnityEvent is a serialized field with no custom inspector?
All ways I tried so far seem to take to a dead end.

Hello,
In your OnInspectorGUI() method try this one:

 EditorGUILayout.PropertyField(YOUR_EVENTS_SERIALIZEDPROPERTY, true);

This will invoke PropertyField with this signature:

public static bool PropertyField(SerializedProperty property, bool includeChildren, params GUILayoutOption[] options);

so the second argument will do the trick.

Adding to woofdcr’s answer, which helped, I found this to be a nice way to expose lists of classes and structs.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

[System.Serializable]
public class MetaEvent
{
    public int ID;
    public UnityEvent Event;
}

[System.Serializable]
public class MetaEventSet : MonoBehaviour {
    public List<MetaEvent> metaEvents;
}

And for the editor part:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(MetaEventSet))]
public class MetaEventSetEditor : Editor {

    public override void OnInspectorGUI()
    {
        MetaEventSet _target = (MetaEventSet)target;

        EditorGUILayout.PropertyField(serializedObject.FindProperty("metaEvents"), true);
        serializedObject.ApplyModifiedProperties();
    }

}

This renders UnityEvents plus other fields nicely:

87062-2017-01-31-16-49-59-program-manager.png

@ Rs this way can not add event