detecting last frame of video[MovieTexture]

Right now I have the following simple script to play a Movietexture on a Plane. I want to be able to detect the last frame so I can trigger a countdown script in another Text component. What changes do I need to make?

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 Answer

1

You can use

if(!movie.isPlaying) //if false tigger a countdown

OR

You can get duration of your movie in seconds by

clipDuration = movie.duration;

and trigger your countdown