After updating my storybook app, I encountered a problem with a function that no longer works. The script on the gameobject containing my audio track used to fade the screen to black and load the next scene when the audio track ended.
I'm an artist who cobbled together this script years ago with the help of some forum users - can someone guide me on how to fix it? I suspect that some syntax has become obsolete or something similar?
The fading out and level loading work fine when I press the "page turn" button in the app, but the issue seems to be specifically related to the audio triggering the end event.
It appears that the script is stuck in the while loop:
function Start()
{
Screen.sleepTimeout = 0.0f; // disable auto-dimming
PlayAudio();
}
function PlayAudio()
{
GetComponent.<AudioSource>().Play();
while(GetComponent.<AudioSource>().time < GetComponent.<AudioSource>().clip.length){
yield; //do nothing if the audio is still playing
}
//once the audio stops, proceed to load the level
if(AdventManager.AdventMode)
{
// Half-fade the scene in Advent mode
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);
// Show back/forward/rewind buttons
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);
// Go to the next page
Application.LoadLevel (Application.loadedLevel+1);
}
}