Hello. I am trying to, as the title suggests, access the light component of multiple gameobjects in unity. I must do this in order to make certain lights in my scene, in this case Torches along a cave wall, to all be of a certain color and intensity. I have tried:
Light[] torchLight;
void Start () {
torchLight = FindObjectsOfType(typeof(Light)) as Light[];
foreach(Light light in lights)
{
light.intensity = 10;
light.color = Color.yellow;
Debug.Log(light);
}
}
But the Issue with this is that it affects the other lights that I have in my scene. I would like for just a few specific lights to follow these values. I have also tried:
void Start ()
{
torchLight = GameObject.FindGameObjectsWithTag ("Torch").GetComponent<Ligjht>();
foreach (Light light in torchLight)
{
light.color = Color.yellow;
light.intensity = 8;
Debug.Log (light);
}
}
But it says that System.array does not contain a definition of GetComponent. Any Ideas?