using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Video; public class MediaItem : MonoBehaviour { public string media_type; public Image image_media; public RawImage video_media; public VideoPlayer player; public void InitImage(Sprite _sprite) { media_type = "image"; image_media.sprite = _sprite; image_media.gameObject.SetActive(true); video_media.gameObject.SetActive(false); } public void InitVideo(string url) { image_media.gameObject.SetActive(false); video_media.gameObject.SetActive(true); media_type = "video"; player.url = url; player.Play(); } private void Update() { if (player.isPlaying) { video_media.texture = player.texture; } } }