i have a class called gameObject and one of it’s properties in called component and is of type object:
public object component;
and i’m trying to use this object to act as an object that can hold object of any class you give it. for example
unit c = new unit(...)
gameObject test = new gameObject(...)
test.component = c;
and i want to use the c object through the component object. for example
if(test.component==typeof(unit))
test.component.Draw();//draw is a function of the unit object
is this possible to do? and how do i do it?
Yes, it’s called casting. Like this: