Global Game Jam 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
732 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class ImageAnimator : MonoBehaviour
  5. {
  6. [SerializeField]
  7. private GameObject[] m_Panels;
  8. [SerializeField]
  9. private float m_time = 0.5f;
  10. private int m_count;
  11. private void OnEnable()
  12. {
  13. m_count = 0;
  14. StartCoroutine(PanelSequence(m_time));
  15. }
  16. private IEnumerator PanelSequence(float waitTime)
  17. {
  18. foreach (var panel in m_Panels)
  19. panel.SetActive(false);
  20. m_Panels[m_count].SetActive(true);
  21. m_count = (m_count + 1) % m_Panels.Length;
  22. yield return new WaitForSeconds(waitTime);
  23. StartCoroutine(PanelSequence(waitTime));
  24. }
  25. }