- Home /
How to make this script load next level after audio stops playing
Hi Guys. I found out this plays my video.
var movTexture : MovieTexture;
function Start () {
renderer.material.mainTexture = movTexture;
movTexture.Play();
}
How would i make this load the next scene after the video or audio has stoped playing. I have seen some other questions of the same idea but i can not get a definitive answer. Would love all the information you can share. thank you.
Answer by _EdzUp_ · Jul 04, 2012 at 07:12 PM
personally I would do a simple:
if ( movTexture.isPlaying == false ) {
Application.LoadLevel( "MyLevel" );
}
There are several reasons this can be beneficial to other method one is simply the whole game can continue execution without being stuck in a do..while loop so for instance you could have a loverly background effect running through and once the sound stops it then moves on and loads the level.
love it... But could ask you how would i implement this into my 1st script i linked. because im fairly new to unity and not really sure where this is to be placed.
I would place it in function Update this way it will allow the system to check whilst its all running
Answer by whydoidoit · Jul 04, 2012 at 06:05 PM
Like this:
function Start () {
renderer.material.mainTexture = movTexture;
movTexture.Play();
do
{
yield null;
} while (movTexture.isPlaying);
Application.LoadLevel(whatever);
}
I think that's a C# - JS hybrid =]
function Start () {
renderer.material.mainTexture = movTexture;
movTexture.Play();
yield;
while (movTexture.isPlaying)
{
yield;
}
Application.LoadLevel(whatever);
}
var movTexture : $$anonymous$$ovieTexture;
function Start () { renderer.material.mainTexture = movTexture; movTexture.Play(); do { yield null; } while (movTexture.isPlaying); Application.LoadLevel(1); }
Causes a internal unity error that stops me clicking play. I remove the script from assets and it fixes the bug but i cant implement this script. Can you see something wrong with it? Because it doesnt come up with a error over the script but something about internal output = boo error
And you want to make sure a frame has passed before testing isPlaying I found something that didn't return playing on the first frame a while ago...
sorry, fair enough. Just a pattern my brain recognized and said 'hey, that's C#' . Also thanks for the wait-a-frame-before-checking-isPlaying tip, good to know.
Answer by Luci85 · Jul 04, 2012 at 06:03 PM
I would somehow measure how long the movTexture playtime is and make a counter which loads the scene after the time is lapsed.
Your answer
Follow this Question
Related Questions
Video Texture Loop 2 Answers
Movie script stops video half way ? 1 Answer
Have null errors 1 Answer
Importing the Island Demo 1 Answer
Make Script Disable 3 Answers