我最近更新了我的故事书应用程序,但功能已停止工作。我在游戏对象上有一个脚本,我的音轨将屏幕淡化成黑色,并在音轨结束时加载下一个场景。
我是一名艺术家,多年前在一些论坛海报的帮助下一起破解了这个剧本 - 有人能告诉我如何更改剧本以使其再次起作用吗?我假设某些语法已经过时了?
当我点击应用程序中的“翻页”按钮时淡出和水平加载工作 - 这是由音频结束触发的那个似乎完全是问题。
似乎这永远不会离开while循环:
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);
}
}
答案 0 :(得分:0)
请尝试替换此部分代码:
while(GetComponent.<AudioSource>().time < GetComponent.<AudioSource>().clip.length){
yield; //if the audio is playing, don't do anything
}
有了这个:
yield WaitForSeconds(GetComponent.<AudioSource>().clip.length);