Closed DarrenRuaneKaizen closed 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.
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:
CustomEditorUtility.cs
in the methodGetDrawersByInheritedInspectedTypesFromAttributes
there is a check forif (!targetType.IsClass)
with a comment saying "value types don't support inheritance". Interface types will returnfalse
here. TheType.IsValueType
is preferable to check for value types.targetType.GetExtendingType
which will only check the type against known Unity components/scriptable objects if it is a type that derives fromUnityEngine.Object
(which interfaces will not).Type.IsSubclassOf
throughout the codebase which will not return true for types that implement interfaces (instead theType.IsAssignableFrom
method could be used).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!)