MovieScreen.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Video;
  5. public class MovieScreen : MonoBehaviour
  6. {
  7. [SerializeField]
  8. private UnityEngine.Video.VideoPlayer mPlayer;
  9. [SerializeField]
  10. private GameObject ExtralObj;//附带的显示
  11. [SerializeField]
  12. private MeshRenderer mRender;
  13. void Start()
  14. {
  15. mRender = transform.Find("movie_logo").GetComponent<MeshRenderer>();
  16. mPlayer = mRender.GetComponent<VideoPlayer>();
  17. mPlayer.clip = Resources.Load<VideoClip>("movie_ani/logo_movie_base");
  18. mRender.gameObject.SetActive(false);
  19. mRender.gameObject.SetActive(true);
  20. mPlayer.Play();
  21. // ExtralObj = transform.GetChild(0).gameObject;
  22. // mRender = transform.Find("movie_logo").GetComponent<MeshRenderer>();
  23. // // mPlayer = transform.Find("Video").GetComponent<VideoPlayer>();
  24. //// mPlayer = mRender.GetComponent<VideoPlayer>();
  25. // mPlayer.targetMaterialRenderer = mRender;
  26. // //mRender.enabled = false;
  27. // //if (ExtralObj != null)
  28. // //{
  29. // // ExtralObj.SetActive(false);
  30. // //}
  31. // //StartCoroutine(CheckMovie());
  32. // //if (mPlayer == null)
  33. // // return;
  34. // //mRender.enabled = true;
  35. // ////if (ExtralObj != null)
  36. // ////{
  37. // //// ExtralObj.SetActive(false);
  38. // ////}
  39. // //ExtralObj.SetActive(true);
  40. // //mPlayer.Play();
  41. // StartCoroutine(Player());
  42. }
  43. private IEnumerator Player()
  44. {
  45. mPlayer.enabled = false;
  46. yield return new WaitForSeconds(1f);
  47. mPlayer.gameObject.AddComponent<VideoPlayer>();
  48. }
  49. private void Update()
  50. {
  51. // mPlayer.Play();
  52. }
  53. //private void OnEnable()
  54. //{
  55. // if (mPlayer == null)
  56. // return;
  57. // mRender.enabled = true;
  58. // //if (ExtralObj != null)
  59. // //{
  60. // // ExtralObj.SetActive(false);
  61. // //}
  62. // ExtralObj.SetActive(true);
  63. // mPlayer.Play();
  64. // // StartCoroutine(CheckMovie());
  65. //}
  66. //IEnumerator CheckMovie()
  67. //{
  68. // yield return null;
  69. // while(!mPlayer.isPlaying)
  70. // {
  71. // //CDebug.Log("-->" + mRender.material.mainTexture);
  72. // yield return new WaitForSecondsRealtime(1);
  73. // }
  74. // mRender.enabled = true;
  75. // if (ExtralObj != null)
  76. // {
  77. // ExtralObj.SetActive(true);
  78. // }
  79. //}
  80. }