I’ve been trying out how to access the light component of the lights to turn off or be disabled. How would I set it up so all objects with the light component will be disabled
You should be able to access it like so
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Lights : MonoBehaviour
{
public List<GameObject> LightList = new List<GameObject>();
void Start ()
{
foreach (var light in LightList)
{
light.GetComponent<Light>().enabled = false;
}
}
}
Hope this helps.
Light lights = FindObjectsOfType();
foreach(Light light in lights)
{
light.gameObject = value;
}
A deactivated object cannot be found using Unity Find methods. So best would be to perform a search in a Start and use the array later on via a method.