2014-09-23 38 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