Look off. doc at Thread.Sleep Method .
System.Threading.Thread.Sleep (50);
Answer 1, authority 100%
The asynchronous method was great:
await Task.Delay ()
Answer 2
In general, if you need to make a delay during the cycle in Unity, there is a good option with Coroutine:
bool isBusy = false;
public GameObject [] players = new GameObject [4];
private void Update ()
{
if (! isBusy)
{
StartCoroutine (Wait ());
}
}
IEnumerator Wait () {
isBusy = true;
foreach (GameObject player in players) {
Debug.log ("player =" + player.name);
yield return new WaitForSeconds (4);
StopCoroutine (Wait ());
}
isBusy = false;
}
In WaitForSeconds, you simply pass how long to delay.
Answer 3
I do this (in fact, it’s the same as what Alex Kapustin did, only the challenge is slightly different) :
// subclass libraries
using System;
using System.Threading;
...
Thread.Sleep (1000); // sleep for one second