SerializeReference drawer that allows you to populate the property with instance inheriting the given type.
By default [SerializeReference] fields display empty data with no UI to populate it, so you can't do anything with it. You need some custom property drawer like this one to draw the interface for you.
Use [WiseSerializeReferenceDrawer] attribute next to [SerializeReference] to have a "+" button drawn next to the field. Pressing it will ask you to select the type to be instantiated - any class that inherits or implements the target field type. Populated fields will display the instance type name which can be clicked to be copied or pinged if possible.
[SerializeReference]
[WiseSerializeReferenceDrawer]
public MyClass SomeField;If you want to customize the drawer or have this behaviour everywhere, not just the given field (per type, not per field) have a property drawer editor that inherits WiseSerializeReferenceBasePropertyDrawer.
If you use [SerializeReference] with lists and you want to avoid duplicated references to the same instance, use WiseSerializeReferenceValidation.ClearDuplicateReferences(this) in your OnValidate() function!
- Download the single file directly: WiseSerializeReferenceDrawer.cs
- Asset Store
- OpenUPM support:
npm install -g openupm-cli
openupm add devlocker.utils.wiseserializereferencedrawer
- Github upm package - merge this to your
Packages/manifest.json
{
"dependencies": {
"devlocker.utils.wiseserializereferencedrawer": "https://github.com/NibbleByte/UnityWiseSerializeReference.git#upm"
}
