#if UNITY_2019_1_OR_NEWER
using UnityEngine;
using UnityEngine.UIElements;
namespace UnityAtoms.Editor
{
///
/// Custom editor for Events. Adds the possiblity to raise an Event from Unity's Inspector.
///
/// The type of this event..
/// Event of type T.
public abstract class AtomEventInstancerEditor : UnityEditor.Editor
where E : AtomEvent
{
public override VisualElement CreateInspectorGUI()
{
var root = new VisualElement();
IMGUIContainer defaultInspector = new IMGUIContainer(() => DrawDefaultInspector());
root.Add(defaultInspector);
var eventInstancer = target as AtomEventInstancer;
E atomEvent = eventInstancer.Event;
var runtimeWrapper = new VisualElement();
runtimeWrapper.SetEnabled(Application.isPlaying);
runtimeWrapper.Add(new Button(() =>
{
atomEvent.Raise(eventInstancer.InspectorRaiseValue);
})
{
text = "Raise"
});
root.Add(runtimeWrapper);
return root;
}
}
}
#endif