【问题标题】:Application.LoadLevel not working in Unity3dApplication.LoadLevel 在 Unity3d 中不起作用
【发布时间】:2014-10-30 07:44:22
【问题描述】:

我有问题。现在我正在Unity中开发游戏,条件为2分。我想等待十秒钟才能进行代码更改场景(Application.LoadLevel)(我正在使用C#进行开发)

但是这段代码当 score = 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);
}

它可以运行和编译不是没有错误。

【问题讨论】:

    标签: c# unity3d kinect


    【解决方案1】:

    将场景加载放在协程中。

     yield return new WaitForSeconds(10);
     Application.LoadLevel("scene_a5");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多