其实就和你显示图片,音频什么的一样的道理。视频一般是面形式展现的
第一步:在场景中新建一个面(plane对象) GameObject ->create other -> plane
第二步:新建一个script脚本文件控制视频的播放(这里提供的是C#脚本 Script_moveTest.cs) 代码如下
using UnityEngine;
using System.Collections;
public class Script_moveTest: MonoBehaviour {
//电影纹理
public MovieTexture mov;
// Use this for initialization
void Start () {
//设置当前对象的纹理是电影纹理
renderer.material.mainTexture = mov;
//设置为循环播放
mov.loop = true;
}
void OnGUI()
{
if(GUILayout.Button("播放/继续播放")){
if(!mov.isPlaying){
mov.Play();
}
}
if(GUILayout.Button("暂停播放")){
mov.Pause();
}
if(GUILayout.Button("停止播放")){
mov.Stop();
}
}
}
第三步:将该脚本绑定到第一步中创建的plane对象上,并给脚本赋值你要播放的视频纹理。
你就可以运行了,(打这么久挺累的)望采纳!!谢谢
public movietexture movtexture;
void start()
{
//电影纹理
renderer.material.maintexture = movtexture;
//设置电影纹理播放模式为循环
//movtexture.loop = true;
}
void ongui()
{
if(guilayout.button("播放/继续"))
{
if(!movtexture.isplaying)
{
movtexture.play();
}
}
if(guilayout.button("暂停播放"))
{
movtexture.pause();
}
if(guilayout.button("停止播放"))
{
movtexture.stop();
}
}
将需要播放的视频,拖入为“movtexture”的对象赋值
Photoshop|
Dreamweaver|
SVG|
WebGL|
Visual Studio|
PowerDesigner|
Eclipse|
Git|
Apache Ant|
Atom|
Composer|
CodeSmith|
Flex|
Gradle|
Maven|
Sublime Text3|
SVN|
Tableau|
Vim|
Chrome开发者工具|
OpenGL|
Unity|
Direct3D|
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....