Assigning Serializable child class, not visible in Editor

I have a Person MonoBehaviour class:

public class Person : MonoBehaviour {
	public string name;
	public Animal pet;
}

An serializable abstract Animal class:

[System.Serializable]
public abstract class Animal {
	public string name;
	public virtual void Run () {}
}

Also a Cat class inherited from Animal

[System.Serializable]
public class Cat : Animal {
    public string catType;
	public override void Run () {Debug.Log ("Cat Run");}
}

Then in editor I cannot directly assign the pet to a person:
76269-screen-shot-2016-08-17-at-85236-pm.png


However, if I specifically assign Cat to Person, it works:

public class Person : MonoBehaviour {
	public string name;
	public Cat pet;
}

76276-screen-shot-2016-08-17-at-92236-pm.png

But that isn’t what I want: e.g. Tom always has Cat as pet, while Peter can have Dog

The only way I can think of is making Animal a MonoBehaviour, create a prefab, attach the Cat to the prefab, and finally drag the prefab to Person.

This is also not preferable because Animal doesn’t need to be MonoBehaviour and this can create a lot of prefabs.

Can this be solved by using custom editor? So I can drag the Cat script to Person, then the editor know the pet is a Cat type and display the Cat variables, etc.

You can define a “custom property drawer” for the Animal Class, which should then show up the in default editor for your Person::MonoBehavior. (note: a “custom property drawer”, is different from a “custom editor”- the custom property drawer defines how a “field”, of the specified class, is to be drawn.)

A custom editor WOULD also work, but you would have to redo the editor code that “reads” and displays the Animal, for every monobehavior that uses the Animal class.

Alternatively, you can also simply make Animal NOT abstract; and return some default values, rather than have virtual functions. This option will NOT show additional fields that Cat has, so probably not what you want.