49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
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<LightSwitch>();
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
}
|
|
} |