PlayList.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.InputSystem;
  5. using UnityEngine.UI;
  6. public class PlayList : MonoBehaviour
  7. {
  8. public GameObject[] playListObjects1;
  9. public GameObject[] playListObjects;
  10. /// <summary>
  11. /// 等待时间
  12. /// </summary>
  13. private float waitTime;
  14. /// <summary>
  15. /// 答案数据
  16. /// </summary>
  17. private List<bool> saveData;
  18. private void Start()
  19. {
  20. StartPlayState2();
  21. }
  22. public void Skip()
  23. {
  24. waitTime = 0.5f;
  25. }
  26. /// <summary>
  27. /// 播放课堂行为管理
  28. /// </summary>
  29. public void StartPlayState1()
  30. {
  31. saveData = new List<bool>();
  32. StartCoroutine(StartPlayState2Coroutine(playListObjects1));
  33. }
  34. /// <summary>
  35. /// 播放高级认知提问
  36. /// </summary>
  37. public void StartPlayState2()
  38. {
  39. saveData = new List<bool>();
  40. StartCoroutine(StartPlayState2Coroutine(playListObjects));
  41. }
  42. private IEnumerator StartPlayState2Coroutine(GameObject[] objects)
  43. {
  44. for (int i = 0; i < objects.Length; i++)
  45. {
  46. yield return StartCoroutine(WaitTime(objects[i]));
  47. }
  48. }
  49. private IEnumerator WaitTime(GameObject obj)
  50. {
  51. obj.SetActive(true);
  52. SelectPrefab selectPrefab = obj.GetComponent<SelectPrefab>();
  53. if (selectPrefab == null)
  54. {
  55. waitTime = obj.GetComponent<AudioSource>().clip.length;
  56. }
  57. else
  58. {
  59. waitTime = 9999999;
  60. selectPrefab.SelectPrefabCreateInit((bool value) =>
  61. {
  62. waitTime = 0;
  63. });
  64. }
  65. while (waitTime > 0)
  66. {
  67. waitTime -= Time.deltaTime;
  68. yield return null;
  69. }
  70. obj.SetActive(false);
  71. }
  72. }
粤ICP备19079148号