using SO; using SO.Channels; using UnityEngine; using UnityEngine.Video; namespace Managers { public class VideoManager : MonoBehaviour { [SerializeField] private VideoPlayer videoPlayer; [SerializeField] private StepChangeChannelSO stepChangeChannel; [SerializeField] private SimpleChannelSO playChannel; [SerializeField] private SimpleChannelSO stopChannel; [SerializeField] private SimpleChannelSO videoChannel; private void OnEnable() { stepChangeChannel.OnStepChanged += OnStepChanged; playChannel.OnEventRaised += Play; stopChannel.OnEventRaised += Stop; videoChannel.OnEventRaised += VideoPanelEnabled; } private void OnDisable() { stepChangeChannel.OnStepChanged -= OnStepChanged; playChannel.OnEventRaised -= Play; stopChannel.OnEventRaised -= Stop; videoChannel.OnEventRaised -= VideoPanelEnabled; } private void OnStepChanged(StepSO step) { videoPlayer.clip = step.Video; videoPlayer.Play(); } private void VideoPanelEnabled() { Play(); } private void Play() { Stop(); videoPlayer.Play(); } private void Stop() { videoPlayer.Stop(); videoPlayer.frame = 0; } } }