Closed mnicolas94 closed 10 months ago
Sorry for the very late reply. I had reservations as to whether a new feature should be implemented.
If I am correct, the issue may have been resolved in the following release https://github.com/mackysoft/Unity-SerializeReferenceExtensions/releases/tag/1.1.9
This release allows SubclassSelector to retrieve and handle custom drawers for subclasses.
I hope the issue has been resolved.
Description
The problem:
I have and interface and I want to select subclasses with SubclassSelector attribute. One of the subclasses has its own PrepertyDrawer. Let's look to an example code:
The problem is the property drawer of SubclassB wont be used as it competes with SubclassSelectorDrawer because both drawers are applied to the same field
_interface
.MySolution
Instead of an attribute I used a generic class
SubclassSelector<T>
that have aSerializeReference
field. I added this class to your code so users can use eitherSubclassSelectorAttribute
orSubclassSelector<T>
depending on their needs. The usage is as follows:Advantages:
Disadvantages
_interface
you have call_interface.Value
which is more verbose.Value
is a property ofSubclassSelector<T>
that returns the value of the actual object you want.Changes made
I created the class
SubclassSelector.cs
insideMackySoft.SerializeReferenceExtensions.Runtime
folder. The code is simpleSubclassSelectorGenericDrawer.cs
insideMackySoft.SerializeReferenceExtensions.Editor
folder. This has the drawer code and is almost identical to yourSubclassSelectorDrawer.cs
.