Search Unity

Custom property drawer for Generic Scriptable Objects

Discussion in 'Editor Workflows' started by JakHussain, Nov 7, 2019.

  1. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    In the current 2020.1 alpha, serialization of generic classes and structs is finally a thing. You can see all the fields in the inspector and it works with the JSONUtility class. But when I tried this with a generic scriptable object, instead of showing an object field to drag in my asset, the inspector just serialized the fields.

    My first thought was to try and write a custom property drawer to force it to draw an asset field which can accept concrete instances or derived classes from my generic scriptable object class but I'm not really sure where to start with that since there's no documentation on generic property drawers or property drawers of generic types.