StepManager.cs 1005 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using TMPro;
  4. using UnityEngine;
  5. namespace Unity.VRTemplate
  6. {
  7. /// <summary>
  8. /// Controls the steps in the in coaching card.
  9. /// </summary>
  10. public class StepManager : MonoBehaviour
  11. {
  12. [Serializable]
  13. class Step
  14. {
  15. [SerializeField]
  16. public GameObject stepObject;
  17. [SerializeField]
  18. public string buttonText;
  19. }
  20. [SerializeField]
  21. public TextMeshProUGUI m_StepButtonTextField;
  22. [SerializeField]
  23. List<Step> m_StepList = new List<Step>();
  24. int m_CurrentStepIndex = 0;
  25. public void Next()
  26. {
  27. m_StepList[m_CurrentStepIndex].stepObject.SetActive(false);
  28. m_CurrentStepIndex = (m_CurrentStepIndex + 1) % m_StepList.Count;
  29. m_StepList[m_CurrentStepIndex].stepObject.SetActive(true);
  30. m_StepButtonTextField.text = m_StepList[m_CurrentStepIndex].buttonText;
  31. }
  32. }
  33. }