- Home /
Question by
peachpieproductions · Jan 18, 2018 at 09:30 PM ·
getcomponentcastcasting
Upcasting via GetComponent<>()
Okay so I have class A and class B, B inherits from A.
I am trying to cast B to A by using something like:
inst = Instantiate();
inst.AddComponent(B);
inst.GetComponent<A>().variable = value;
The variable is not being set to the value. There is no errors, just nothing being set as far as I can tell.
Is there a better way to go about setting variables in a script after its been upcast?
Comment