40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using InfallibleCode;
|
|
|
|
public class ManageLightSwitchesInScene : MonoBehaviour
|
|
{
|
|
[SerializeField] private NewLightSwitch[] _lightSwitches;
|
|
|
|
private static ManageLightSwitchesInScene _instance;
|
|
public static ManageLightSwitchesInScene GetInstance() { return _instance; }
|
|
|
|
private void Awake()
|
|
{
|
|
if (!_instance)
|
|
{
|
|
_instance = this;
|
|
}
|
|
|
|
_lightSwitches = FindObjectsOfTypeAll(typeof(NewLightSwitch)) as NewLightSwitch[];
|
|
}
|
|
|
|
public void TurnOffAllLights()
|
|
{
|
|
foreach (NewLightSwitch allLightSwitches in _lightSwitches) //objectRefrence not set to instance of an object error here
|
|
{
|
|
allLightSwitches.LightOff();
|
|
allLightSwitches.canTurnOnLight = false;
|
|
}
|
|
}
|
|
|
|
public void TurnOnAllLights()
|
|
{
|
|
foreach (NewLightSwitch allLightSwitches in _lightSwitches) //objectRefrence not set to instance of an object error here
|
|
{
|
|
allLightSwitches.LightOn();
|
|
}
|
|
}
|
|
}
|