1
我遇到問題。現在我在Unity中開發遊戲,條件是得分2.我想等待10秒鐘之後再做代碼更改場景(Application.LoadLevel)(我正在使用C#進行開發)Application.LoadLevel在Unity3d中不起作用
但是這段代碼當得分= 2這將改變爲「scenea_5」 不能再等待十秒鐘
void OnTriggerEnter(Collider collider){
if (collider.name == front_hztleft) {
audio.Play();
}
if (collider.name == left_hztleft) {
audio.Play();
score ++;
Debug.Log (string.Format (scoreSyntax, score));
endtime = DateTime.Now.ToString("HH:mm:ss");
InsertResult();
}
if (score == 2) {
StartCoroutine(Waiting());
Application.LoadLevel("scene_a5");
}
}
IEnumerator Waiting()
{
yield return new WaitForSeconds (10);
}
它可以運行和編譯沒有錯誤。