想等待几秒之后切换场景
代码如下:
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == ("hongqiu2"))
{
//撞到red2后,发出碰撞的声音
AudioSource.PlayClipAtPoint(achongqiu, gameObject.transform.position);
Destroy(col.collider.gameObject);
Destroy(gameObject);
Instantiate(red3, gameObject.transform.position, Quaternion.Euler(new Vector3(0, 0, 0)));
victory1 = true;
if (PengZhuangLv.victory2 && PengZhuang.victory1)
{
StartCoroutine(Wait(2.0f));
}
}
}
IEnumerator Wait(float waitSeconds)
{
yield return new WaitForSeconds(waitSeconds);
Application.LoadLevel("win");
}
}
yield return new WaitForSeconds(waitSeconds);后面的语句不能执行
请问为什么阿。
代码如下:
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == ("hongqiu2"))
{
//撞到red2后,发出碰撞的声音
AudioSource.PlayClipAtPoint(achongqiu, gameObject.transform.position);
Destroy(col.collider.gameObject);
Destroy(gameObject);
Instantiate(red3, gameObject.transform.position, Quaternion.Euler(new Vector3(0, 0, 0)));
victory1 = true;
if (PengZhuangLv.victory2 && PengZhuang.victory1)
{
StartCoroutine(Wait(2.0f));
}
}
}
IEnumerator Wait(float waitSeconds)
{
yield return new WaitForSeconds(waitSeconds);
Application.LoadLevel("win");
}
}
yield return new WaitForSeconds(waitSeconds);后面的语句不能执行
请问为什么阿。