2019-05-06 00:03:43 +02:00
|
|
|
#if UNITY_2019_1_OR_NEWER
|
2018-10-30 20:05:06 +01:00
|
|
|
using UnityEditor;
|
|
|
|
using UnityEngine;
|
2019-05-06 00:03:43 +02:00
|
|
|
using UnityEngine.UIElements;
|
|
|
|
using UnityEditor.UIElements;
|
2018-10-30 20:05:06 +01:00
|
|
|
|
2019-09-27 17:48:18 +02:00
|
|
|
namespace UnityAtoms.Editor
|
2018-10-30 20:05:06 +01:00
|
|
|
{
|
2019-09-25 21:05:06 +02:00
|
|
|
public abstract class AtomEventEditor<T, E> : UnityEditor.Editor
|
|
|
|
where E : AtomEvent<T>
|
2018-10-30 20:05:06 +01:00
|
|
|
{
|
2019-05-06 00:03:43 +02:00
|
|
|
protected T _raiseValue = default(T);
|
|
|
|
|
|
|
|
protected virtual VisualElement GetRaiseValueInput() { return null; }
|
2018-10-30 20:05:06 +01:00
|
|
|
|
2019-05-06 00:03:43 +02:00
|
|
|
public override VisualElement CreateInspectorGUI()
|
|
|
|
{
|
2019-05-07 22:37:50 +02:00
|
|
|
var wrapper = new VisualElement();
|
|
|
|
wrapper.SetEnabled(Application.isPlaying);
|
2018-10-30 20:05:06 +01:00
|
|
|
|
2019-05-06 00:03:43 +02:00
|
|
|
var input = GetRaiseValueInput();
|
|
|
|
if (input != null)
|
2018-10-30 20:05:06 +01:00
|
|
|
{
|
2019-05-07 22:37:50 +02:00
|
|
|
wrapper.Add(input);
|
2018-10-30 20:05:06 +01:00
|
|
|
}
|
2019-05-06 00:03:43 +02:00
|
|
|
|
2019-05-07 22:37:50 +02:00
|
|
|
wrapper.Add(new Button(() =>
|
2019-05-06 00:03:43 +02:00
|
|
|
{
|
|
|
|
E e = target as E;
|
|
|
|
e.Raise(_raiseValue);
|
|
|
|
})
|
|
|
|
{
|
|
|
|
text = "Raise"
|
|
|
|
});
|
|
|
|
|
2019-05-07 22:37:50 +02:00
|
|
|
return wrapper;
|
2018-10-30 20:05:06 +01:00
|
|
|
}
|
|
|
|
}
|
2019-04-07 11:10:09 +02:00
|
|
|
}
|
2019-05-06 00:03:43 +02:00
|
|
|
#endif
|