Unity在UGUI上播放视频的办法

先在Canvas添加RawImage组件。

然后在RawImage挂载如下脚本。

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Test : MonoBehaviour
{
    //电影纹理
    public MovieTexture movTexture;

    void Start()
    {
        //设置电影纹理播放模式为循环
        movTexture.loop = true;
        movTexture.Play();
        RawImage ri =  gameObject.GetComponent<RawImage>();
        ri.texture = movTexture;
    }

}

接下来使用TheoraConverter.NET 1.1 将mp4 转成ogv。这样就免去类Unity要安装movetime player,quictime什么一大堆莫名问题。(来源于网上)。

然后将该ogv视频加入资源。将该资源直接拖到如上脚本的movTexture即可。

猜你喜欢

转载自blog.csdn.net/glunoy/article/details/53158046