x


On movie end

Hi Guys,

I am having an issue with triggering an event when a movie completes. I am using the isPlaying property of the movie texture to check however it is never set to true.

    GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), Intro);

Intro.Play();

if(Intro.isPlaying == false) {

    GUI.Label(Rect(25, Screen.height / 2, 500, 500), "Here is some Content", IntroText);
    Debug.Log("Video NOT Playing");

} else {

    Debug.Log("Video Playing");

}

Any Ideas on how I can trigger an event when the movie ends?

Thanks.

more ▼

asked Jan 05 '12 at 03:29 PM

tex1820 gravatar image

tex1820
1 3 3 3

Sorry to bump this but dose anyone have an answer? I am on a deadline

Jan 06 '12 at 03:56 AM tex1820
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first

Hi Tex,

Here is something that may help you.

void PlayMyClip()
{    

 if(!Intro.isPlaying)
 {
    // Play clip
    Intro.Play();

    // Wait for the clip to finish
    StartCoroutine(Wait(_currentClip.duration));

    //
    // Add your code here
    //

 }

}

private IEnumerator Wait(float duration)
{
    yield return new WaitForSeconds(duration);
}

The idea is pretty simple. First you trigger the clip to play and then wait for it to finish using yield. Once it finishes playing you can carry on with your other stuff.

You can of course send a message after the wait function call or do something a little more advanced (read complicated :) ) depending on your actual requirements.

Hope this helps.

more ▼

answered Feb 08 '12 at 07:10 PM

alexfeature gravatar image

alexfeature
196 3

(comments are locked)
10|3000 characters needed characters left
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x117
x107
x2

asked: Jan 05 '12 at 03:29 PM

Seen: 1083 times

Last Updated: Feb 08 '12 at 10:05 PM