using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Sirenix.OdinInspector; using KairoEngine.Core.GameActions; namespace KairoEngine.UI { [HideMonoScript] public class SlideshowController : MonoBehaviour { [SerializeField, ShowInInspector] private List slides = new List(); public bool executeOnStart = true; [HideLabel, InlineProperty, FoldoutGroup("OnEnd")] public GameActionsController endActionController = new GameActionsController(); private bool started = false; private bool finished = false; private int slideIndex = 0; private void Start() { for (int i = 0; i < slides.Count; i++) slides[i].Hide(); if(executeOnStart) started = true; } private void Update() { if(started == false) return; if(finished == true) return; if(slideIndex >= slides.Count) { endActionController.Start(); finished = true; return; } var done = slides[slideIndex].UpdateSlide(); if(done) { slides[slideIndex].Hide(); slideIndex += 1; } } public void StartSlideShow() => started = true; } }