Uinity學習的一些知識點
阿新 • • 發佈:2019-02-15
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); }
取消視訊播放(即是跳過視訊)
2、RequireComponent(自動新增關聯的指令碼) 如: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; }
[RequireComponent (typeof(XXXX))]
3、