I have a custom PropertyDrawer for drawing the fields of a ScriptableObject.
It works great with PowerInspector for the most part but it does not get used when a declared field type is abstract (even though the injected type is a derived, non-abstract type).
To clarify on that, here's what I've got in my project:
A ScriptableObject called RoomLayoutGenerator which is marked as abstract.
A type deriving from RoomLayoutGenerator called LinearRoomLayoutGenerator which is not marked as abstract
A MonoBehaviour which declares a private serialized field of type RoomLayoutGenerator (note: the abstract one)
In the Editor I inject an instance of the LinearRoomLayoutGenerator into the field on the MonoBehaviour
In doing this, I would expect my custom property drawer to be used, but instead the AbstractDrawer is used.
Removing the abstract qualifier from the base type solves the problem but I'd like to refrain from doing this as it introduces a code-smell into my project.
Similarly, changing the declared type on the MonoBehaviour to one of the derived types solves this too, but of course that defeats the entire purpose of what I'm trying to achieve (a strategy pattern-like approach using ScriptableObject).
I understand that this may not be an "issue" so-to-speak but if there is a more elegant way for me to get my custom drawer used on a declared abstract type that'd be fantastic.
I have a custom
PropertyDrawer
for drawing the fields of aScriptableObject
. It works great with PowerInspector for the most part but it does not get used when a declared field type isabstract
(even though the injected type is a derived, non-abstract
type).To clarify on that, here's what I've got in my project:
ScriptableObject
calledRoomLayoutGenerator
which is marked asabstract
.RoomLayoutGenerator
calledLinearRoomLayoutGenerator
which is not marked asabstract
MonoBehaviour
which declares aprivate
serialized field of typeRoomLayoutGenerator
(note: theabstract
one)LinearRoomLayoutGenerator
into the field on theMonoBehaviour
In doing this, I would expect my custom property drawer to be used, but instead the
AbstractDrawer
is used.Removing the
abstract
qualifier from the base type solves the problem but I'd like to refrain from doing this as it introduces a code-smell into my project.Similarly, changing the declared type on the
MonoBehaviour
to one of the derived types solves this too, but of course that defeats the entire purpose of what I'm trying to achieve (a strategy pattern-like approach usingScriptableObject
).I understand that this may not be an "issue" so-to-speak but if there is a more elegant way for me to get my custom drawer used on a declared abstract type that'd be fantastic.
Thanks for your help.