ReferencePickerA dropdown to pick a referenced value for Unity's SerializeReference.
You can use this to pick non UnityObject object like interface or polymorphism class. If the target has custom drawer, the drawer will be used.
Limitation:
- The target must have a public constructor with no required arguments.
- It'll try to copy field values when changing types but not guaranteed.
structwill not get copied value (it's too tricky to deal a struct)
Parameters:
bool hideLabel=false: true to hide the label of picked type
Allow Multiple: No
using SaintsField; [Serializable] public class Base1Fruit { public GameObject base1; } [Serializable] public class Base2Fruit: Base1Fruit { public int base2; } [Serializable] public class Apple : Base2Fruit { public string apple; public GameObject applePrefab; } [Serializable] public class Orange : Base2Fruit { public bool orange; } [SerializeReference, ReferencePicker] public Base2Fruit item; public interface IRefInterface { public int TheInt { get; } } // works for struct [Serializable] public struct StructImpl : IRefInterface { [field: SerializeField] public int TheInt { get; set; } public string myStruct; } [Serializable] public class ClassDirect: IRefInterface { [field: SerializeField, Range(0, 10)] public int TheInt { get; set; } } // abstract type will be skipped public abstract class ClassSubAbs : ClassDirect { public abstract string AbsValue { get; } } [Serializable] public class ClassSub1 : ClassSubAbs { public string sub1; public override string AbsValue => quot;Sub1: {sub1}"; } [Serializable] public class ClassSub2 : ClassSubAbs { public string sub2; public override string AbsValue => quot;Sub2: {sub2}"; } [SerializeReference, ReferencePicker] public IRefInterface myInterface;

If you have custom drawer of that type, the drawer will be used: