12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 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<SlideData> slides = new List<SlideData>();
- 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;
-
- }
- }
|