You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
670 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.Video;
  6. public class videoToUI : MonoBehaviour
  7. {
  8. public RawImage rawImage;
  9. public VideoPlayer videoPlayer;
  10. // Use this for initialization
  11. void Start()
  12. {
  13. StartCoroutine(PlayVideo());
  14. }
  15. IEnumerator PlayVideo()
  16. {
  17. videoPlayer.Prepare();
  18. WaitForSeconds waitForSeconds = new WaitForSeconds(1);
  19. while (!videoPlayer.isPrepared)
  20. {
  21. yield return waitForSeconds;
  22. break;
  23. }
  24. rawImage.texture = videoPlayer.texture;
  25. videoPlayer.Play();
  26. }
  27. }