using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnableScriptTrigger : MonoBehaviour { [SerializeField] private MonoBehaviour scriptToEnable; [SerializeField] private LightSwitch lightSwitch; private bool UpdateThisLight; void Start() { //scriptToEnable.enabled = false; lightSwitch = GetComponentInChildren(); } // Update is called once per frame void Update() { if (UpdateThisLight) { lightSwitch.lightSwitch(); print("IsRunningLightSwitch()"); } } private void OnTriggerStay(Collider col) { if (col.gameObject.tag == "Player") { if (LightsManager.GetInstance().CanInteractWithLight) { UpdateThisLight = true; } else { UpdateThisLight = false; } } } private void OnTriggerExit(Collider col) { if (col.gameObject.tag == "Player") { UpdateThisLight = false; } } }