Display Property based on its dynamic type

class Animal {
public int age;

class Tiger: Animal {
public GameObject prey;

class Deer: Animal {
public string feed;
class MyClass: monobehaviour{
public Animal MyAnimal;

Say in the scenario above, and I’m writing a custom inspector for MyClass. Is there a way to display the field ‘MyAnimal’ according to its actual type. E.g if it’s a tiger, display age and prey; If it’s a deer, display age and feed.


I have figured out a solution which can be found in my blog here. http://www.stephengou.com/blog/unity-dynamic-property-field