unity-atoms/Packages/BaseAtoms/Editor/Drawers/Collections/AtomCollectionReferenceDrawer.cs

31 lines
1.3 KiB
C#
Raw Normal View History

2020-03-18 00:17:33 +01:00
using UnityEditor;
using UnityAtoms.Editor;
namespace UnityAtoms.BaseAtoms.Editor
{
/// <summary>
/// A custom property drawer for AtomCollectionReference. Makes it possible to choose between a Collection or a Collection Instancer.
/// </summary>
[CustomPropertyDrawer(typeof(AtomCollectionReference), true)]
public class AtomCollectionReferenceDrawer : AtomBaseReferenceDrawer
{
protected class UsageCollection : UsageData
{
public override int Value { get => AtomCollectionReferenceUsage.COLLECTION; }
public override string PropertyName { get => "_collection"; }
public override string DisplayName { get => "Use Collection"; }
}
protected class UsageCollectionInstancer : UsageData
{
public override int Value { get => AtomCollectionReferenceUsage.COLLECTION_INSTANCER; }
public override string PropertyName { get => "_instancer"; }
public override string DisplayName { get => "Use Collection Instancer"; }
}
private readonly UsageData[] _usages = new UsageData[2] { new UsageCollection(), new UsageCollectionInstancer() };
protected override UsageData[] GetUsages(SerializedProperty prop = null) => _usages;
}
}