2019-05-05 18:03:43 -04:00
|
|
|
#if UNITY_2019_1_OR_NEWER
|
2018-10-30 15:05:06 -04:00
|
|
|
using UnityEditor;
|
|
|
|
using UnityEngine;
|
2019-05-05 18:03:43 -04:00
|
|
|
using UnityEngine.UIElements;
|
|
|
|
using UnityEditor.UIElements;
|
2018-10-30 15:05:06 -04:00
|
|
|
|
2019-09-27 11:48:18 -04:00
|
|
|
namespace UnityAtoms.Editor
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-09-25 15:05:06 -04:00
|
|
|
public abstract class AtomEventEditor<T, E> : UnityEditor.Editor
|
|
|
|
where E : AtomEvent<T>
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-05-05 18:03:43 -04:00
|
|
|
protected T _raiseValue = default(T);
|
|
|
|
|
|
|
|
protected virtual VisualElement GetRaiseValueInput() { return null; }
|
2018-10-30 15:05:06 -04:00
|
|
|
|
2019-05-05 18:03:43 -04:00
|
|
|
public override VisualElement CreateInspectorGUI()
|
|
|
|
{
|
2019-09-29 19:24:02 -04:00
|
|
|
var root = new VisualElement();
|
|
|
|
|
|
|
|
var desc = serializedObject.FindProperty("_developerDescription");
|
|
|
|
var developerDescription = new TextField("Developer Description") { value = desc.stringValue, multiline = true };
|
|
|
|
developerDescription.RegisterCallback<ChangeEvent<string>>(evt =>
|
|
|
|
{
|
|
|
|
desc.stringValue = evt.newValue;
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
});
|
|
|
|
root.Add(developerDescription);
|
|
|
|
|
|
|
|
var runtimeWrapper = new VisualElement();
|
|
|
|
runtimeWrapper.SetEnabled(Application.isPlaying);
|
2018-10-30 15:05:06 -04:00
|
|
|
|
2019-05-05 18:03:43 -04:00
|
|
|
var input = GetRaiseValueInput();
|
|
|
|
if (input != null)
|
2018-10-30 15:05:06 -04:00
|
|
|
{
|
2019-09-29 19:24:02 -04:00
|
|
|
runtimeWrapper.Add(input);
|
2018-10-30 15:05:06 -04:00
|
|
|
}
|
2019-05-05 18:03:43 -04:00
|
|
|
|
2019-09-29 19:24:02 -04:00
|
|
|
runtimeWrapper.Add(new Button(() =>
|
2019-05-05 18:03:43 -04:00
|
|
|
{
|
|
|
|
E e = target as E;
|
|
|
|
e.Raise(_raiseValue);
|
|
|
|
})
|
|
|
|
{
|
|
|
|
text = "Raise"
|
|
|
|
});
|
2019-09-29 19:24:02 -04:00
|
|
|
root.Add(runtimeWrapper);
|
2019-05-05 18:03:43 -04:00
|
|
|
|
2019-09-29 19:24:02 -04:00
|
|
|
return root;
|
2018-10-30 15:05:06 -04:00
|
|
|
}
|
|
|
|
}
|
2019-04-07 05:10:09 -04:00
|
|
|
}
|
2019-05-05 18:03:43 -04:00
|
|
|
#endif
|