VideoGCController.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Video;
  5. public class VideoGCController : MonoBehaviour
  6. {
  7. [SerializeField]
  8. private VideoPlayer Video;
  9. [SerializeField]
  10. private GameObject Screen;
  11. [SerializeField]
  12. private GameObject CheckObj;
  13. private void Awake()
  14. {
  15. CheckObj.gameObject.SetActive(false);
  16. Screen.gameObject.SetActive(true);
  17. Video.gameObject.SetActive(true);
  18. }
  19. void Start()
  20. {
  21. Video.Play();
  22. StartCoroutine(VideoCallBack(Video));
  23. }
  24. private IEnumerator VideoCallBack(VideoPlayer VideoObject)
  25. {
  26. yield return new WaitForSeconds(1);
  27. while (VideoObject.isPlaying)
  28. {
  29. yield return new WaitForFixedUpdate(); //跟FixedUpdate 一样根据固定帧 更新
  30. }
  31. CDebug.Log("视频播放完毕");
  32. CheckObj.gameObject.SetActive(true);
  33. Screen.gameObject.SetActive(false);
  34. Destroy(this.gameObject);
  35. }
  36. }