unity-atoms/Packages/FSM/Editor/Drawers/FiniteStateMachineReferenceDrawer.cs

31 lines
1.2 KiB
C#
Raw Normal View History

2020-03-08 19:16:40 -04:00
using UnityEditor;
using UnityAtoms.Editor;
namespace UnityAtoms.FSM.Editor
{
/// <summary>
2020-03-11 16:11:27 -04:00
/// A custom property drawer for FiniteStateMachineReference. Makes it possible to choose between a FSM or a FSM Instancer.
2020-03-08 19:16:40 -04:00
/// </summary>
[CustomPropertyDrawer(typeof(FiniteStateMachineReference), true)]
public class FiniteStateMachineReferenceDrawer : AtomBaseReferenceDrawer
{
2020-03-11 16:11:27 -04:00
protected class UsageFSM : UsageData
2020-03-08 19:16:40 -04:00
{
2020-03-11 16:11:27 -04:00
public override int Value { get => FiniteStateMachineReferenceUsage.FSM; }
public override string PropertyName { get => "_fsm"; }
public override string DisplayName { get => "Use FSM"; }
2020-03-08 19:16:40 -04:00
}
2020-03-11 16:11:27 -04:00
protected class UsageFSMInstancer : UsageData
2020-03-08 19:16:40 -04:00
{
2020-03-11 16:11:27 -04:00
public override int Value { get => FiniteStateMachineReferenceUsage.FSM_INSTANCER; }
public override string PropertyName { get => "_fsmInstancer"; }
public override string DisplayName { get => "Use FSM Instancer"; }
2020-03-08 19:16:40 -04:00
}
2020-03-11 16:11:27 -04:00
private readonly UsageData[] _usages = new UsageData[2] { new UsageFSM(), new UsageFSMInstancer() };
2020-03-08 19:16:40 -04:00
protected override UsageData[] GetUsages(SerializedProperty prop = null) => _usages;
}
}