2014-09-23 54 views
2

現在我有了以下簡單的腳本來在平面上播放Movietexture。我希望能夠檢測到最後一幀,以便在另一個Text組件中觸發倒計時腳本。我需要做些什麼改變?統一 - 在MovieTexture中檢測視頻的最後一幀

using UnityEngine; 
using System.Collections; 

[RequireComponent (typeof (AudioSource))] 
public class VideController : MonoBehaviour { 

    // Use this for initialization 
    void Start() { 
     Screen.SetResolution (768, 1024, false, 60); 
     MovieTexture movie = renderer.material.mainTexture as MovieTexture; 
     audio.clip = movie.audioClip; 
     audio.Play(); 
     movie.Play(); 
    } 

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

    } 
} 
+1

快速谷歌產生了這些解決方案:HTTP:// forum.unity3d.com/threads/on-movie-end-switch-levels.47929/ http://answers.unity3d.com/questions/202303/on-movie-end.html – Imapler 2014-09-23 05:57:18

回答

1

您可以在更新檢查,如果電影結束與否,並設置一個布爾值,以不開始倒計數每幀

void Update() { 
    if(!movie.isPlaying && inCountDown=false) 
    { 
     //start the count down 
    inCountDown=true; 
    } 
} 
+0

謝謝。失望的視頻選項是如此有限的統一。你應該能夠獲得視頻的幀#等 – 2014-09-23 11:45:58

+0

只是使用協同程序... http://answers.unity3d.com/questions/202303/on-movie-end.html#answer-1000687 – Fattie 2015-07-05 08:55:08

相關問題