MovieScreen.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. UnityEngine.Object @object = ResMgr.Instance.Load("logo_movie_base");
  18. VideoClip gameObject = UnityEngine.Object.Instantiate<VideoClip>(@object as VideoClip);
  19. mPlayer.clip = gameObject;// Resources.Load<VideoClip>("movie_ani/logo_movie_base");
  20. mRender.gameObject.SetActive(false);
  21. mRender.gameObject.SetActive(true);
  22. mPlayer.Play();
  23. // ExtralObj = transform.GetChild(0).gameObject;
  24. // mRender = transform.Find("movie_logo").GetComponent<MeshRenderer>();
  25. // // mPlayer = transform.Find("Video").GetComponent<VideoPlayer>();
  26. //// mPlayer = mRender.GetComponent<VideoPlayer>();
  27. // mPlayer.targetMaterialRenderer = mRender;
  28. // //mRender.enabled = false;
  29. // //if (ExtralObj != null)
  30. // //{
  31. // // ExtralObj.SetActive(false);
  32. // //}
  33. // //StartCoroutine(CheckMovie());
  34. // //if (mPlayer == null)
  35. // // return;
  36. // //mRender.enabled = true;
  37. // ////if (ExtralObj != null)
  38. // ////{
  39. // //// ExtralObj.SetActive(false);
  40. // ////}
  41. // //ExtralObj.SetActive(true);
  42. // //mPlayer.Play();
  43. // StartCoroutine(Player());
  44. }
  45. private IEnumerator Player()
  46. {
  47. mPlayer.enabled = false;
  48. yield return new WaitForSeconds(1f);
  49. mPlayer.gameObject.AddComponent<VideoPlayer>();
  50. }
  51. private void Update()
  52. {
  53. // mPlayer.Play();
  54. }
  55. //private void OnEnable()
  56. //{
  57. // if (mPlayer == null)
  58. // return;
  59. // mRender.enabled = true;
  60. // //if (ExtralObj != null)
  61. // //{
  62. // // ExtralObj.SetActive(false);
  63. // //}
  64. // ExtralObj.SetActive(true);
  65. // mPlayer.Play();
  66. // // StartCoroutine(CheckMovie());
  67. //}
  68. //IEnumerator CheckMovie()
  69. //{
  70. // yield return null;
  71. // while(!mPlayer.isPlaying)
  72. // {
  73. // //CDebug.Log("-->" + mRender.material.mainTexture);
  74. // yield return new WaitForSecondsRealtime(1);
  75. // }
  76. // mRender.enabled = true;
  77. // if (ExtralObj != null)
  78. // {
  79. // ExtralObj.SetActive(true);
  80. // }
  81. //}
  82. }