MovieScreen.cs 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class MovieScreen : MonoBehaviour
  5. {
  6. [SerializeField]
  7. private UnityEngine.Video.VideoPlayer mPlayer;
  8. [SerializeField]
  9. private GameObject ExtralObj;//附带的显示
  10. private MeshRenderer mRender;
  11. void Awake()
  12. {
  13. mRender = this.gameObject.GetComponent<MeshRenderer>();
  14. }
  15. private void OnEnable()
  16. {
  17. mRender.enabled = false;
  18. if(ExtralObj != null)
  19. {
  20. ExtralObj.SetActive(false);
  21. }
  22. StartCoroutine(CheckMovie());
  23. }
  24. IEnumerator CheckMovie()
  25. {
  26. yield return null;
  27. while(!mPlayer.isPlaying)
  28. {
  29. //CDebug.Log("-->" + mRender.material.mainTexture);
  30. yield return new WaitForSecondsRealtime(1);
  31. }
  32. mRender.enabled = true;
  33. if (ExtralObj != null)
  34. {
  35. ExtralObj.SetActive(true);
  36. }
  37. }
  38. }