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
603 B

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