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

33 lines
941 B
C#
Executable File

using SO;
using SO.Channels;
using UnityEngine;
using UnityEngine.UI;
namespace Managers
{
public class DocumentManager : MonoBehaviour
{
[SerializeField] private StepChangeChannelSO stepChangeChannel;
[SerializeField] private SimpleChannelSO documentLoadedChannel;
[SerializeField] private Material currentImage;
private const string MainText = "_MainTex";
private static readonly int MainTex = Shader.PropertyToID(MainText);
private void OnEnable()
{
stepChangeChannel.OnStepChanged += OnStepChanged;
}
private void OnDisable()
{
stepChangeChannel.OnStepChanged -= OnStepChanged;
}
private void OnStepChanged(StepSO step)
{
currentImage.SetTexture(MainTex, step.Document);
documentLoadedChannel.RaiseEvent();
}
}
}