timo-sisus / Power-Inspector

Report bugs and offer improvement ideas for Power Inspector.
http://u3d.as/1sNc
7 stars 0 forks source link

Custom PropertyDrawer targeting interface type doesn't get used #20

Closed DarrenRuaneKaizen closed 4 years ago

DarrenRuaneKaizen commented 4 years ago

I've got a custom property drawer targeting an interface like the following: [CustomPropertyDrawer(typeof(IEditorClampableVariable), true)]

It works perfectly using the native Unity inspector but PowerInspector doesn't seem to detect it at all. I took a look through the source and made a few observations that may be of some help:

I understand that there is probably a lot of work involved in making Drawers work when targeting interfaces but my workflow now involves switching back-and-forth between the native inspector and PowerInspector very frequently (when ideally I would like to just stay in PowerInspector!)

timo-sisus commented 4 years ago

Support for Property Drawers and Decorator Drawers targeting interfaces will be added in Update 1.3.4. I also implemented support for targeting interfaces for custom editors - even though this is not even supported in the default inspector - because why not? Unity doesn't seem to complain if you pass an interface parameter to CustomEditorAttribute in any case.

The usage of IsSubclassOf throughout the code bass is intentional, as I always make a clear distinction between getting extending classes of a base class and getting implementing classes of an interface as early as possible for various reasons. I just had not realized that you even could create custom property drawers targeting interfaces.