本文介绍了在Unity 5.5个人版中播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了MovieTexture类,以播放来自Unity C#脚本的视频,但是MovieTexture用于Unity Pro,并且我没有Pro版本.

I looked at the MovieTexture class, to play videos from Unity's C# scripting, but MovieTexture is for Unity Pro, and I don't have the Pro version.

我还查看了PlayFullScreenMovie,以播放视频,但是仅当我将视频作为资源导入Unity的Project文件夹中时,该方法才起作用.

I also looked at PlayFullScreenMovie, to play videos, but that works only if I import the video as an asset inside Unity's Project folder.

我的问题是:是否可以在不将视频导入为资产的情况下以Unity Personal Edition播放视频?就像,我可以使用计算机中视频的文件位置(文件路径)作为播放视频的源URL吗?谢谢.

My question is: Is there a way to play a video in Unity Personal edition, without importing the video as an asset? Like, can I use the video's file location (filepath) in the computer as the source url to play the video from? Thanks.

推荐答案

不正确. Unity 5.0发布之后,Unity的仅专业版API和工具在所有版本的Unity中都可用.您可以在Unity 5.5中使用MovieTexture.

Not true. After Unity 5.0 release, pro only API and tools in Unity became available in all version of Unity. You can use MovieTexture in Unity 5.5.

如果您的目标是从Internet,URL,本地网络或文件夹中播放视频,请忽略PlayFullScreenMovie.不是为了这个.

If your goal is to play video from the internet, url, local network or folder, forget about PlayFullScreenMovie. It's not made for that.

您可以使用MovieTexture进行此操作.请注意,MovieTexture有一个很大的限制.例如,我从未见过它播放.mp4视频.它播放.ogg电影.由于您不想使用 Unity 5.6 ,您只能使用MovieTexture进行操作.它无法在移动设备上播放视频.

You can do this with MovieTexture. Note that there is a big limitation with MovieTexture. For example, I've never seen it play .mp4 video before. It plays .ogg movie. Since you don't want to use Unity 5.6, you are very limited to things you can do with MovieTexture. It can't play video on mobile devices.

MovieTexture movieTexture;
AudioSource vidAudio;
public RawImage rawImage;

void Start()
{
    WWW www = new WWW("http://techslides.com/demos/sample-videos/small.ogv");
    movieTexture = www.GetMovieTexture();
    rawImage.texture = movieTexture;

    vidAudio = gameObject.AddComponent<AudioSource>();
    vidAudio.clip = movieTexture.audioClip;
}

void Update()
{
    if (movieTexture.isReadyToPlay && !movieTexture.isPlaying)
    {
        movieTexture.Play();
        vidAudio.Play();
    }

    if (movieTexture.isPlaying)
    {
        rawImage.texture = movieTexture;
    }
}

剩下的剩下的选择是购买视频插件或制作一个.这些非常昂贵,所以这里是最上班的. AVPro视频轻松的影片纹理.

That remaining option left is to buy a video plugin or make one. These are very expensive so here are the top working ones. AVPro Video and Easy Movie Texture.

这篇关于在Unity 5.5个人版中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 00:54