Make a common superclass, like ‘animal’ and derive ‘fish’ and ‘bird’ from ‘animal’ Then if the var is of type ‘animal’ it should accept ‘fish’ or ‘bird’
untested:
class Animal ( can add 'extends MonoBehaviour' here if it would be such a thing)
{
var legs : int; // for example
}
class Bird implements Animal
{
Bird() { legs = 2; } // constructor to initialize whatever
}
class Fish implements Animal
{
Fish() { legs = 0; }
}
var f : Fish = new Fish();
var b : Bird = new Bird();
var a : Animal;
a = f;
a = b;