I am familiar with the basic way of getting components by
ASpecificComponent aSpecificComponent = (ASpecificComponent)transform.GetComponent("ASpecificComponent");
aSpecificComponent.anInt = 0;
However, now I have an array of components and I want to do something like:
compnentArray[1].anInt = 0;
or
Component aComponent = compnentArray[1];
aComponent.anInt = 0;
Trying to do that yields this error: Assets/Scripts/CharController.cs(111,38): error CS1061: Type `UnityEngine.Component' does not contain a definition for `anInt' and no extension method `anInt' of type `UnityEngine.Component' could be found (are you missing a using directive or an assembly reference?)
I suspect that it is not possible to do what I want to do but that there is something else that you do in a situation like this. By the way, all of the scripts in the array of components have a variable named anInt.
↧