using System.Collections; using System.Collections.Generic; using UnityEngine; public class CustomLight : MonoBehaviour { // Start is called before the first frame update void OnEnable() { CustomLightRegistry.Instance.Register(this); } // Update is called once per frame void OnDisable() { CustomLightRegistry.Instance.Unregister(this); } } public class CustomLightRegistry : Singleton { private List m_Lights; public List lights { get { if (m_Lights == null) m_Lights = new List(); return m_Lights; } } public void Register(CustomLight renderer) { if (!lights.Contains(renderer)) { lights.Add(renderer); } } public void Unregister(CustomLight renderer) { lights.Remove(renderer); } }