using System.Collections; using System.Collections.Generic; using Assets.HeroEditor.Common.Scripts.Common; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; public class CreditsController : MonoBehaviour{ public TextMeshProUGUI firstText; // This, and the next 4 TMPs are individual credit screens public TextMeshProUGUI secondText; public TextMeshProUGUI thirdText; public TextMeshProUGUI fourthText; public TextMeshProUGUI fifthText; public AudioSource creditsMusic; // The music for the credits private bool first = false; // This, and the next 4 bools are to play the credits in a sequence private bool second = false; private bool third = false; private bool fourth = false; private bool fifth = false; // Start is called before the first frame update void Start(){ // Initialize the credits music and begin to play it creditsMusic = GetComponent(); creditsMusic.Play(); // Set screens 2 through 5 to inactive and activate the first secondText.SetActive(false); thirdText.SetActive(false); fourthText.SetActive(false); fifthText.SetActive(false); firstText.SetActive(true); first = true; // Start the credit coroutine StartCoroutine(RollCredits()); } IEnumerator RollCredits(){ // Wait on each credit screen for 10 seconds yield return new WaitForSeconds(10f); // If we just played the first screen, then set the bool to false and deactivate the credit if (first){ first = false; firstText.SetActive(false); // Activate the second credit screen and set its bool to true; repeat the process until done secondText.SetActive(true); second = true; StartCoroutine(RollCredits()); } else if (second){ second = false; secondText.SetActive(false); thirdText.SetActive(true); third = true; StartCoroutine(RollCredits()); } else if (third){ third = false; thirdText.SetActive(false); fourthText.SetActive(true); fourth = true; StartCoroutine(RollCredits()); } else if (fourth){ fourth = false; fourthText.SetActive(false); fifthText.SetActive(true); fifth = true; StartCoroutine(RollCredits()); } else if (fifth){ // After the fifth credit screen, load us back to the Title Screen SceneManager.LoadScene("TitleScreen"); } } }