Не работает WaitForSeconds()
Добавлено: 28 мар 2021, 18:32
Есть вот такой вот кусок скрипта:
players>0, но при выполнении скрипта сразу перекидывает на сцену "game". Где может быть ошибка?
Синтаксис:
Используется csharp
void Update()
{
for (int i = 0; i < players; i++)
{
role.text = $"Player {i + 1}, get ready!";
StartCoroutine(waitFiveSecs());
if (roles[i] == 1)
{
role.text = $"You're a spy";
}
else
{
role.text = $"You're in the {place}";
}
StartCoroutine(waitFiveSecs());
}
SceneManager.LoadScene("game");
}
IEnumerator waitFiveSecs()
{
yield return new WaitForSeconds(5);
}
{
for (int i = 0; i < players; i++)
{
role.text = $"Player {i + 1}, get ready!";
StartCoroutine(waitFiveSecs());
if (roles[i] == 1)
{
role.text = $"You're a spy";
}
else
{
role.text = $"You're in the {place}";
}
StartCoroutine(waitFiveSecs());
}
SceneManager.LoadScene("game");
}
IEnumerator waitFiveSecs()
{
yield return new WaitForSeconds(5);
}
players>0, но при выполнении скрипта сразу перекидывает на сцену "game". Где может быть ошибка?