c# Sleep
using System.Threading;
static void Main()
{
//do stuff
Thread.Sleep(5000) //will sleep for 5 sec
}
c# Sleep
using System.Threading;
static void Main()
{
//do stuff
Thread.Sleep(5000) //will sleep for 5 sec
}
c# wait for seconds
using System;
using System.Threading;
class Example
{
static void Main()
{
for (int i = 0; i < 5; i++)
{
Console.WriteLine("Sleep for 2 seconds.");
Thread.Sleep(2000);
}
Console.WriteLine("Main thread exits.");
}
}
/* This example produces the following output:
Sleep for 2 seconds.
Sleep for 2 seconds.
Sleep for 2 seconds.
Sleep for 2 seconds.
Sleep for 2 seconds.
Main thread exits.
*/
c# wait seconds
//wait 2 seconds
Thread.Sleep(2000);
Task.Delay(2000);
//Both are valid options but I would recommend Task.Delay() as you can still use your UI while waiting
wait C#
void Start()
{
StartCoroutine(waiter());
}
IEnumerator waiter()
{
//Rotate 90 deg
transform.Rotate(new Vector3(90, 0, 0), Space.World);
//Wait for 4 seconds
yield return new WaitForSeconds(4);
//Rotate 40 deg
transform.Rotate(new Vector3(40, 0, 0), Space.World);
//Wait for 2 seconds
yield return new WaitForSeconds(2);
//Rotate 20 deg
transform.Rotate(new Vector3(20, 0, 0), Space.World);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us