Stratasys-450mc-VR/Assets/Scripts/Managers/DocumentUpdater.cs
2023-11-05 22:05:29 -05:00

30 lines
861 B
C#

using System.Collections;
using System.Collections.Generic;
using SO;
using SO.Channels;
using UnityEngine;
using UnityEngine.UIElements;
public class DocumentUpdater : MonoBehaviour
{
[SerializeField] private StepChangeChannelSO stepChangeChannel;
[SerializeField] private SimpleChannelSO documentLoadedChannel;
[SerializeField] private UnityEngine.UI.Image currentImage;
private void OnEnable()
{
stepChangeChannel.OnStepChanged += OnStepChanged;
}
private void OnDisable()
{
stepChangeChannel.OnStepChanged -= OnStepChanged;
}
private void OnStepChanged(StepSO step)
{
currentImage.sprite = (Sprite.Create((Texture2D)step.Document, new Rect(0, 0, step.Document.width, step.Document.height), new Vector2(0.5f, 0.5f)));
documentLoadedChannel.RaiseEvent();
}
}