SlideData.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using Sirenix.OdinInspector;
  6. namespace KairoEngine.UI
  7. {
  8. [System.Serializable]
  9. public class SlideData
  10. {
  11. [FoldoutGroup("@title")] public string title = "New Slide";
  12. [FoldoutGroup("@title")] public bool skipable = true;
  13. [FoldoutGroup("@title")] public Image image;
  14. [FoldoutGroup("@title")] public float delay = 0.5f;
  15. [FoldoutGroup("@title")] public float duration = 3f;
  16. [FoldoutGroup("@title")] public UiAnimator uiAnimator;
  17. private float counter = 0;
  18. private bool hasDelayed = false;
  19. public void Show()
  20. {
  21. //Debug.Log("Showing slide " + title);
  22. image.gameObject.SetActive(true);
  23. counter = 0f;
  24. hasDelayed = false;
  25. }
  26. public void Hide()
  27. {
  28. if(uiAnimator) uiAnimator.Disable();
  29. else image.gameObject.SetActive(false);
  30. }
  31. public bool UpdateSlide()
  32. {
  33. counter += Time.deltaTime;
  34. if(!hasDelayed)
  35. {
  36. if(counter > delay)
  37. {
  38. Show();
  39. hasDelayed = true;
  40. }
  41. }
  42. else
  43. {
  44. if(counter > duration)
  45. {
  46. //Debug.Log("Showing slide " + title + " is done");
  47. return true;
  48. }
  49. else return false;
  50. }
  51. return false;
  52. }
  53. }
  54. }