mirror of
https://udrimavric.com/MAVRIC/Stratasys-450mc-VR.git
synced 2025-01-23 07:38:33 -05:00
56 lines
1.5 KiB
C#
Executable File
56 lines
1.5 KiB
C#
Executable File
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;
|
|
}
|
|
}
|
|
}
|