unity coroutine
using UnityEngine;
using System.Collections;// In this example we show how to invoke a coroutine and execute
// the function in parallel. Start does not need IEnumerator.public class ExampleClass : MonoBehaviour
{
private IEnumerator coroutine; void Start()
{
// - After 0 seconds, prints "Starting 0.0 seconds"
// - After 0 seconds, prints "Coroutine started"
// - After 2 seconds, prints "Coroutine ended: 2.0 seconds"
print("Starting " + Time.time + " seconds"); // Start function WaitAndPrint as a coroutine. coroutine = WaitAndPrint(2.0f);
StartCoroutine(coroutine); print("Coroutine started");
} private IEnumerator WaitAndPrint(float waitTime)
{
yield return new WaitForSeconds(waitTime);
print("Coroutine ended: " + Time.time + " seconds");
}
}
void Start() {
StartCoroutine("func"); // Start coroutine named "func"
}
IEnumerator func() {
Debug.Log("Hello");
yield return new WaitForSecondsRealtime(1); //Wait 1 second
Debug.Log("World");
}
Also in C#:
- c# max two values
- panel drag all form c#
- c# implement a superclass in subclass
- c# size of enum
- Unity C# make object face away
- c# object to json string
- how can convert string to int csharp
- convert comma separated string to array c#
- .net core get image from url
- unity custom editor save changes
- read embedded resource c# xml
- C# .net core convert to int round up
- convert string to datetime c#
- c# LCP
- modal dismiss
- c# rsa example
- c# remove from list in foreach
- initialise icollection c#
- what data type should be for contact number in asp.net
- decalre an int list mvc
- c# append array
- c# fileupload example
- POST http://localhost:5001/api/v1/identity/login 500 (Internal Server Error) LoginForm.jsx:39 Error: Request failed with status code 500 at createError (createError.js:16) at settle (settle.js:17) at XMLHttpRequest.handleLoad (xhr.js:61)
- c# try catch error