Simple question, is there a way inside a Custom Inspector to call/use a specific PropertyDrawer to manage the display of a property ? I ask this, because sometimes I have to re-write code that really looks the same when I want a custom inspector for a class that has a property for which I have already wrote a PropertyDrawer.
You have to get the field as a serialized property, then draw it using editorguilayout.propertyField (property)
It’s a bit of a faff to do this iirc (I don’t have code with me ) if the field belongs to the custom editor. Do you have any sample code to go off, so I can give you a more defined solution?
I was able to find this snippet of code which may help you.
public class MyScriptEditor : Editor
{
public override void OnInspectorGUI()
{
var it = serializedObject.GetIterator();
EditorGUI.BeginChangeCheck();
bool Enter = true;
while (it.NextVisible(Enter))
{
if ( it.name == "Robot")
{
EditorGUILayout.ObjectField(it);
}
else
Enter = EditorGUILayout.PropertyField(it);
}
if (EditorGUI.EndChangeCheck())
{
so.ApplyModifiedProperties();
}
}
This pretty much draws the inspector as default, except for my field labelled Robot