您的位置:首页 > 产品设计 > UI/UE

Uinity学习的一些知识点

2015-03-17 23:20 162 查看
Uinity怎么播放视频

要想播放一个后缀名为.mov的视频文件,首先需要先安装一个软件(quickTime),安装quickTime软件的时候,需要以管理员的身份进行安装,要不然会存在问题。

这个视频需要绑定到Main Camera上,并且为其加上脚本,如果想要播放声音,在选中Main Camera后,在Inspector中添加Auto Source,并把play On Awake给打上对勾。

public MovieTexture movTexture;
// Use this for initialization
void Start () {
movTexture.loop = false;
movTexture.Play();
}

// Update is called once per frame
void Update () {

}

void OnGUI(){
GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),movTexture);
}


取消视频播放(即是跳过视频)



void Update () {
//人工干预停止
if(isDrawMov){
if(Input.GetMouseButtonDown(0) && isShowMessage == false){
isShowMessage = true;
}else if(Input.GetMouseButtonDown(0) && isShowMessage == true){
StopMov();
}
}
//正常播放最后一帧停止
if(isDrawMov != movTexture.isPlaying){
StopMov();
}

}

void OnGUI(){

if(isDrawMov){
GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),movTexture);
if(isShowMessage){
GUI.Label(new Rect(Screen.width/2,Screen.height/2,100,10),"退出动画");
}
}
}
private void StopMov(){
movTexture.Stop();
isDrawMov = false;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: