- Home /
Question by
Tumbo The Gnome · Oct 07, 2014 at 04:33 AM ·
c#androidcoroutine
yield return WaitForSeconds not returning for values greater than zero on Android
I have the following code:
public void SetTimer(float time, Action callback)
{
StartCoroutine(this._run_timer(time, callback));
}
private IEnumerator _run_timer(float delay, Action action)
{
Debug.LogWarning("Starting Delayed Action");
Debug.LogWarning("Delay: " + delay);
yield return new WaitForSeconds(delay);
Debug.LogWarning("Wait Complete");
while (this._paused)
{
yield return new WaitForSeconds(0.5f);
}
Debug.LogWarning("Running Action");
action();
Debug.LogWarning("After Everything");
yield return null;
}
When I run my game in Editor and Web Player everything works as expected, but when I build for Android WaitForSeconds never completes if the delay is greater than zero. If the delay is zero the routine will complete and the action is triggered. I've verified that the GameObject the script is attached to isn't being destroyed.
I'm really stumped as to what might be causing this.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613164541im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to solve while loop lags 1 Answer
How to delay gameobject from falling by time? 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
WaitForSeconds(3) on Android waits less than expected 2 Answers