I’m having trouble getting a property drawer to draw an extended class, the setup is something like this;
[System.Serializable]
public class Animal {}
[System.Serializable]
public class Dog : Animal {
public float woofVolume;
}
The class that uses the Dog/Animal class;
public class Kennel : MonoBehaviour {
public Animal animal = new Dog();
}
And the property drawer;
[CustomPropertyDrawer(typeof(Dog))]
public class DogDrawer : PropertyDrawer {
public override void OnGUI (Rect position,
SerializedProperty property,
GUIContent label)
{
EditorGUI.BeginProperty (position, label, property);
GUI.Button(position, "Woof");
EditorGUI.EndProperty ();
}
}
So basically I want the inspector to display the property drawer for Dog when the animal property of kennel is a Dog, if I had a Cat and the appropriate Drawer for a Cat I would want the inspector to use the PropertyDrawer for Cat. Is this achievable with the property drawer system? Currently I can only get it to draw if I make property drawer use typeof(Animal)