Unity Community |

Hello,
as coroutines are very important in optimization processes, making them compatible with a game paused state could be vital.
So here we go :
In your class containing those coroutines (or in any abstract/singleton you want), put these functions :
Code:
public Coroutine _sync(){ } public IEnumerator PauseRoutine(){ while (_myPauseState) { yield return new WaitForFixedUpdate(); } yield return new WaitForEndOfFrame(); }
with _myPauseState being your global pause state.
then in any Coroutines, put this at the end (or at any place you want to check for a pause) :
Code:
yield return _sync();
I personally prefer to put the first code block into a generic baseClass, derived from MonoBehaviour , and then derive all my other "pause-able" classes from it. So I don't have to rewrite the block in all the new pause-able classes.
Kinetic Damage, a 4 years long fighting game project : Official Trailer,
Official Site : www.kineticdamage.com, Facebook page (blog, articles, dev updates).
Dev Blog : Giant thread (+ additional tips & techniques)