UGUI播放视频
作者:互联网
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.UI;
public class PlayVideoOnUGUI : MonoBehaviour {
//定义参数获取VideoPlayer组件和RawImage组件
private VideoPlayer videoPlayer;
private RawImage rawImage;
// Use this for initialization
void Start () {
//获取场景中对应的组件
videoPlayer = this.GetComponent <VideoPlayer> ();
rawImage = this.GetComponent <RawImage> ();
}
// Update is called once per frame
void Update () {
//如果videoPlayer没有对应的视频texture,则返回
if(videoPlayer.texture == null){
return;
}
//把VideoPlayerd的视频渲染到UGUI的RawImage
rawImage.texture = videoPlayer.texture;
}
}
PlayVideoOnUGUI
标签:视频,UnityEngine,RawImage,videoPlayer,texture,rawImage,using,UGUI,播放 来源: https://www.cnblogs.com/Feiyuzhu/p/15694920.html