Mixing custom editors with custom property drawers, possible ?

Is it possible to display custom property drawers inside custom editors ? I’ve been struggling to achieve this result without much luck.

Here’s an oversimplification of my problem:

[Serializable]
public class A
{
    public int intValue;
}

[Serializable]
public class B
{
    public A instanceOfA;
}

I have a custom editor for class B and a custom drawer for class A and i want to use the custom drawer instead of reimplementing the functionality inside the custom editor.

The custom drawer displays fine inside a class that doesn’t have a custom editor (uses the default inspector), but i can’t seem to be able to “call” it inside my custom editor.

From what i’ve read, custom drawers are called if i use the EditorGUILayout.PropertyField method, but the problem with that is it expects a SerializableProperty and i can’t get a hold of one of those since my classes don’t extend Object.

Any help with this would be greatly appreciated, even if it means letting me know that this isn’t yet possible.

Thank you !

I never tried it, but i guess it should be possible. Have you tried using a PropertyField in your custom editor? I think that should actually draw the property with a proper PropertyDrawer.

edit
Well a PropertyField of course needs a SerializedProperty to work with. This can be aquired from a SerializedObject.

Inside a custom editor you already get such an object in the serializedObject variable. Note: If your editor allows multiedit this SerializedObject represents all selected objects at once!

You can also create your own SerializedObject like this:

    SerializedObject obj = new SerializedObject(objectToInspect);
    // And as well by passing an array of objects:
    SerializedObject obj = new SerializedObject(arrayOfObjectsToInspect);

isEditingMultipleObjects can be used to determine if multiple objects are edited. Also important, if you want to support multiediting, is hasMultipleDifferentValues.