Saltar al contenido

cómo usar el ejemplo de código de Waitforseconds unity c #

Ejemplo 1: Retardo de tiempo C # unidad

void start()
StartCoroutine(Text());

IEnumerator Text()  //  <-  its a standalone method
{
	Debug.Log("Hello")
    yield return new WaitForSeconds(3)
    Debug.Log("ByeBye")
}

Ejemplo 2: cómo hacer que una línea de código espere la unidad

//In the example below the script will right "Hello" and 3 seconds later write "Goodbye" in the console
Start()
{
  	//Call the function Example()
	StartCoroutine(Example());
}

Example()
{
  	Debug.Log("Hello");
  	//wait 3 seconds
	yield return new WaitForSeconds(3);
  	Debug.Log("Goodbye");
}

Ejemplo 3: unidad de espera por segundos

public void GameOver()
		{
			//Set levelText to display number of levels passed and game over message
			levelText.text = "After " + level + " months, you starved.";

			new WaitForSeconds(6);

			Application.Quit();


		}
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *