When using get component, is it possible to pass in a string for the name of the component? Currently, I get a number of different errors like
Assets/Scripts/HitBox.cs(36,76): error CS0246: The type or namespace name `aComponent’ could not be found. Are you missing a using directive or an assembly reference?
This is what I want to do.
example:
//of course this would result in a loop, but it's the proper syntax i'm worried about
void update (){
aFunction(theComponentIWantToAccess);
}
void aFunction(string aComponent){
transform.root.GetComponent<aComponent>().anInt++;
}
I get the same issue when I use parentheses instead of <>
i.e.
GetComponent(aComponent)