Make a coroutine run when Time.timeScale = 0;

Hi Guys,

I have been working on a side scroller type game and have alot of my code run in the fixed update method, I currently pause the game using Time.timescale = 0; which works perfectly, however I am adding the in game menu at the moment and would like the buttons to ‘slide’ onto the screen instead of just appear, I have written the following coroutine to make this happen

function Slide() {
    for (var i: int = -10; i < 0; i++) {
        ofset = 10 * i;
        yield WaitForSeconds(0.1f);
    ofset = 0;

with this as my button code

function gamePausedMenu(windowID:int){
	//Restart Button
		GUI.Button(Rect(Screen.width/2 - scoreSize/2 - ofset, Screen.height/2 - (scoreSize/3)/2, scoreSize,scoreSize/3),"Restart", leftTop);
	//Menu Button
		GUI.Button(Rect(Screen.width/2 - scoreSize/2 + ofset, Screen.height/2 + (scoreSize/3), scoreSize,scoreSize/3),"Menu", rightTop);


Now this works perfectly however it doesn’t run at all while Time.timescale = 0, which I do on pause of course, is there any work around to this, so that I can force my that coroutine to run regardless of timescale?

Thanks in Advance!!

Unity now has a special “WaitForSeconds” called WaitForSecondsRealtime which does the same as WaitForSeconds but is not affected by Time.timeScale.

This update renders the other answers out-of-date.

So, in the link below the guy figured it out in an elegant solution that is also re-usable.

public static class CoroutineUtilities 
	public static IEnumerator WaitForRealTime(float delay){
			float pauseEndTime = Time.realtimeSinceStartup + delay;
			while (Time.realtimeSinceStartup < pauseEndTime){
				yield return 0;


yield return StartCoroutine(CoroutineUtilities.WaitForRealTime(1));

I think a really cheap, ugly hack might be to change the yield WaitForSeconds to yield return null;, and take smaller steps:

for(var i : float = -10; i<0; i+=0.3) {
   yield return null;

yield return null; should always wait for the next frame, regardless of timescale. But that messes up the time – it used to finish in 10*0.1=1 second. Now it runs in 10 frames (1/6th to 1/3rd of a second?) So just rewrite the loop to take 30 small 1-frame steps.