- Home /
How to make a level load automatically after a video intro
Hello, I have created a video introduction with MovieTexture that works absolutely fine, no problems. But when it finishes, I want the next level to load. This is what I have so far.
import UnityEngine.GUILayout;
var windowRect = Rect (200, 200, 0, 0);
function Start () {
if (guiTexture.texture.isReadyToPlay) {
guiTexture.texture.loop = false;
guiTexture.texture.Play();
}
}
Screen.lockCursor = true;
Screen.showCursor = false;
This is only the relevant part of the script. I have quite a lot more parts in the whole script, but they are working fine.
Anyway, I want it to load level 1 once the video intro is finished automatically. How would I do this?
Answer by kolban · Apr 15, 2012 at 01:10 PM
I would suggest that using coroutines would be the ideal situation.
Create a function called WaitForMovieToFinish that looks as follows:
function WaitForMovieToFinish(mt:MovieTexture)
{
while(mt.isPlaying)
{
yield;
}
}
In your main code, after you have called Play() on the movie, code the following:
yield WaitForMovieToFinish(guiTexture.texture);
This will wait for the movie to finish while allowing other updates to occur. When the above statement finishes, you can load the new level.
Your answer
Follow this Question
Related Questions
make levels play one after the other... 1 Answer
Unity3d video intro for trailer? 0 Answers
creating play once only 1 Answer
Load Level on Collision 1 Answer
Answer For -> How to Reward Player after watching video - admob rewarded video 0 Answers