unity-atoms/Packages/BaseAtoms/Editor/Drawers/Collections/AtomListReferenceDrawer.cs
2020-03-18 00:17:33 +01:00

31 lines
1.2 KiB
C#

using UnityEditor;
using UnityAtoms.Editor;
namespace UnityAtoms.BaseAtoms.Editor
{
/// <summary>
/// A custom property drawer for AtomListReference. Makes it possible to choose between a List or a List Instancer.
/// </summary>
[CustomPropertyDrawer(typeof(AtomListReference), true)]
public class AtomListReferenceDrawer : AtomBaseReferenceDrawer
{
protected class UsageList : UsageData
{
public override int Value { get => AtomListReferenceUsage.LIST; }
public override string PropertyName { get => "_list"; }
public override string DisplayName { get => "Use List"; }
}
protected class UsageListInstancer : UsageData
{
public override int Value { get => AtomListReferenceUsage.LIST_INSTANCER; }
public override string PropertyName { get => "_instancer"; }
public override string DisplayName { get => "Use List Instancer"; }
}
private readonly UsageData[] _usages = new UsageData[2] { new UsageList(), new UsageListInstancer() };
protected override UsageData[] GetUsages(SerializedProperty prop = null) => _usages;
}
}