Практически полностью подтырил на оф.форуме... Очень полезно, когда есть свое "игровое время".
- Код: Выделить всё
using UnityEngine;
using System.Collections;
public class TimeUtil : MonoBehaviour
{
public Coroutine WaitForGameSeconds(float time)
{
return StartCoroutine(WaitForGameSecondsImpl(time));
}
private IEnumerator WaitForGameSecondsImpl(float time)
{
while (time > 0)
{
//change this line if necessary
time -= Level.game_delta_time;//Time.deltaTime;
yield return 1;
}
}
void Start()
{
StartCoroutine(C());
}
IEnumerator C()
{
yield return WaitForGameSeconds(2);
Debug.Log("Blabla!");
}
}