VideoCopyTexture.cs 729 B

1234567891011121314151617181920212223242526272829303132
  1. using UnityEngine;
  2. using System.Collections;
  3. public class VideoCopyTexture : MonoBehaviour {
  4. public MediaPlayerCtrl m_srcVideo;
  5. // Use this for initialization
  6. void Start () {
  7. }
  8. // Update is called once per frame
  9. void Update () {
  10. if(m_srcVideo != null)
  11. {
  12. if(m_srcVideo.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED || m_srcVideo.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
  13. {
  14. if(m_srcVideo.GetVideoTexture() != null )
  15. {
  16. if(transform.GetComponent<MeshRenderer>().material.mainTexture != m_srcVideo.GetVideoTexture())
  17. {
  18. transform.GetComponent<MeshRenderer>().material.mainTexture = m_srcVideo.GetVideoTexture();
  19. }
  20. }
  21. }
  22. }
  23. }
  24. }