Unity - 在MovieTexture中检测视频的最后一帧

时间:2014-09-23 01:54:33

标签: video unity3d

现在我有以下简单的脚本在平面上播放Movietexture。我希望能够检测到最后一帧,以便我可以在另一个Text组件中触发倒计时脚本。我需要做出哪些改变?

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 个答案:

答案 0 :(得分:1)

你可以检查更新,如果电影结束了,并设置一个bool,不要每帧都开始倒计时

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