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.
 
 

92 regels
2.2 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using Unity.VisualScripting;
  4. using UnityEngine;
  5. using UnityEngine.Video;
  6. public class Coltroller : MonoBehaviour
  7. {
  8. public VideoPlayer player;
  9. public List<VideoClip> clips = new List<VideoClip>();
  10. public List<GameObject> buttons = new List<GameObject>();
  11. int currentIndex = 0;
  12. List<int>[] jumpList = new List<int>[9];
  13. public List<int> endButtons_0 = new List<int>();
  14. public List<int> endButtons_1 = new List<int>();
  15. public List<int> endButtons_2 = new List<int>();
  16. public List<int> endButtons_3 = new List<int>();
  17. public List<int> endButtons_4 = new List<int>();
  18. public List<int> endButtons_5 = new List<int>();
  19. public List<int> endButtons_6 = new List<int>();
  20. public List<int> endButtons_7 = new List<int>();
  21. public List<int> endButtons_8 = new List<int>();
  22. private void Awake()
  23. {
  24. jumpList[0] = endButtons_0;
  25. jumpList[1] = endButtons_1;
  26. jumpList[2] = endButtons_2;
  27. jumpList[3] = endButtons_3;
  28. jumpList[4] = endButtons_4;
  29. jumpList[5] = endButtons_5;
  30. jumpList[6] = endButtons_6;
  31. jumpList[7] = endButtons_7;
  32. jumpList[8] = endButtons_8;
  33. }
  34. private void Start()
  35. {
  36. foreach (GameObject g in buttons)
  37. {
  38. if (g != null)
  39. {
  40. g.SetActive(false);
  41. }
  42. }
  43. buttons[0].SetActive(true);
  44. }
  45. void Update()
  46. {
  47. if (player.isPlaying)
  48. {
  49. double timeLeft = player.clip.length - player.time;
  50. if (timeLeft < 0.3)
  51. {
  52. player.Pause();
  53. foreach (int i in jumpList[currentIndex])
  54. {
  55. if (buttons[i] != null)
  56. {
  57. buttons[i].SetActive(true);
  58. }
  59. }
  60. }
  61. }
  62. }
  63. public void PlayVideo(int _index)
  64. {
  65. currentIndex = _index;
  66. player.clip = clips[_index];
  67. player.Play();
  68. foreach (GameObject g in buttons)
  69. {
  70. g.SetActive(false);
  71. }
  72. }
  73. public void Close()
  74. {
  75. Application.Quit();
  76. }
  77. }