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.
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: