OK, I feel like a complete moron here, because I’ve looked at something like 20 different forum posts revolving around this, and I’m still getting compile errors. I’ve got a couple of spotlights showing on an object, which I want to turn on and off when the object is clicked. Here’s the code I’ve got:
private Light[] lights;
lights = gameObject.GetComponentsInChildren(Light, true);
foreach (Light light in lights) {
light.enabled = true;
}
This seems to me to be the proper format for the GetComponentsInChildren command in C#, but the compiler keeps throwing an error "UnityEngine.Light is a ‘type’ but is used like a ‘variable.’ It is a type, being used as a type, so I don’t know what’s going on.
I’m rusty at C#, so any help would be much appreciated.