Suppose I create a class, ClassA, and have a child class, ClassB which, naturally, inherits from ClassA. Now, say I create a variable, varA, to hold a value of the type ClassA. Can I store on object of type ClassB in varA? Put another way, would the folowing code snippet work:
class ParentClass
{
//class definition
}
class ChildClass extends ParentClass
{
//class definition
}
var blah : ParentClass;
blah = new ChildClass();
And by ‘work’, I mean, is this valid? Would all the member data in the ChildClass object persist in the value of the variable blah?
While I can apreciate the “Teach a Man to Fish” ideology, your suggestion does me no good considering I don’t currently have access to a machine with Unity. I am designing, and I need the question answered to move forward with the design.
Creating a container object. I want it to hold several different kinds of objects, but all of which have the same parent object. Rather than use Array(), I just want to use one fixed array.