赞
踩
1、在UI上添加脚本
添加UITexture脚本 用于显示视频
添加VideoPlayer
2、上代码
VideoPlayer m_Video; UITexture m_Texture; void Start(){ m_Video.started += OnStartVideo;//开始回调 m_Video.loopPointReached += EndWithVideoPlay;//结束回调 } void PlayVideo(VideoClip vlip){ //可以引用外部视频 也可以通过资源加载 RenderTexture targetTexture = RenderTexture.GetTemporary(m_Texture.width, m_Texture.height, 16); m_Texture.mainTexture = targetTexture; m_Video.clip = clip; m_Video.targetTexture = targetTexture; m_Video.isLooping = false; m_Video.Play(); } void OnStartVideo(VideoPlayer source) { //todo 开始播放 } void EndWithVideoPlay(VideoPlayer source) { //TODO播放完成后事件 }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。