Stratasys-450mc-VR/Assets/Scripts/ToggleObjectOff.cs
2023-11-01 10:51:29 -04:00

41 lines
1003 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using SO;
using SO.Channels;
using UnityEngine;
public class ToggleObjectOff : MonoBehaviour
{
[SerializeField] private StepChangeChannelSO stepChangeChannel;
[SerializeField] private SimpleChannelSO previousStepChannel;
[SerializeField] private List<GameObject> objectToDisable;
private void OnEnable()
{
stepChangeChannel.OnStepChanged += OnStepChanged;
previousStepChannel.OnEventRaised += ResetObjects;
}
private void OnDisable()
{
stepChangeChannel.OnStepChanged -= OnStepChanged;
previousStepChannel.OnEventRaised -= ResetObjects;
}
private void OnStepChanged(StepSO step)
{
foreach (GameObject item in objectToDisable)
{
item.SetActive(false);
}
}
private void ResetObjects()
{
foreach (GameObject item in objectToDisable)
{
item.SetActive(false);
}
}
}