xxxxxxxxxx
IEnumerator Start()
{
Debug.Log("Start1");
yield return new WaitForSeconds(2.5f);
Debug.Log("Start2");
}
xxxxxxxxxx
using UnityEngine;
using System.Collections;
public class CoroutineExample : MonoBehaviour
{
void Start()
{
StartCoroutine(MyCoroutine());
}
IEnumerator MyCoroutine()
{
Debug.Log("Coroutine started");
yield return new WaitForSeconds(2f); // Wait for 2 seconds
Debug.Log("Coroutine finished");
}
}