I recently updated my storybook app and a function has stopped working. I had a script on the gameobject with my audio track that faded the screen to black and loaded the next scene when the audio track ended.
I’m an artist and had hacked this script together years ago with the help of some forum posters - could someone tell me how to change the script to make it work again? I assume some syntax has been made obsolete or something?
function Start()
{
Screen.sleepTimeout = 0.0f; // turn off auto-dimming
PlayAudio();
}
function PlayAudio()
{
GetComponent.<AudioSource>().Play();
while(GetComponent.<AudioSource>().time < GetComponent.<AudioSource>().clip.length){
yield; //if the audio is playing, don't do anything
}
//when script gets to here, the audio has stopped playing - load your level
if(AdventManager.AdventMode)
{
// In Advent mode, fade scene halfway
GetComponent.<Renderer>().enabled = true;
Fade.use.Alpha(GetComponent.<Renderer>().material, 0.0, 0.0, 0.0);
Fade.use.Alpha(GetComponent.<Renderer>().material, 0.0, 0.5, 0.5);
yield WaitForSeconds(0.5);
// And display back/forward/rewind buttons
// Instantiate(Resources.Load("EndScene"));
var fwd : GameObject = GameObject.Find("BTN_Fwd");
var back : GameObject = GameObject.Find("BTN_Back");
var reload : GameObject = GameObject.Find("BTN_Reload");
Fade.use.Alpha(fwd.GetComponent.<Renderer>().material, 0.0, 1.0, 0.0);
Fade.use.Alpha(back.GetComponent.<Renderer>().material, 0.0, 1.0, 0.0);
Fade.use.Alpha(reload.GetComponent.<Renderer>().material, 0.0, 1.0, 0.0);
}
else
{
// Fade to black
GetComponent.<Renderer>().enabled = true;
Fade.use.Alpha(GetComponent.<Renderer>().material, 0.0, 0.0, 0.0);
Fade.use.Alpha(GetComponent.<Renderer>().material, 0.0, 1.0, 0.8);
yield WaitForSeconds(0.8);
// And goto next page
Application.LoadLevel (Application.loadedLevel+1);
}
}