wait 3 seconds then resume c#

hello …

am trying to pause my game using time.timescale=0 … but when i want to resume my game after 3 seconds it doesn’t work as i followed this solution:
http://answers.unity3d.com/questions/9878/freeze-game-using-timetimescale-0-wait-3-secs-and.html

and here is my code :

private IEnumerator Pause(int p)
{
    Time.timeScale = 0.1f;
    float pauseEndTime = Time.realtimeSinceStartup + 1;
    while (Time.realtimeSinceStartup < pauseEndTime)
    {
        yield return 0;
    }
    Time.timeScale = 1;
}

void ButtonUp()
{	
    StartCoroutine( Pause() );
    guiTexture.texture = ResumeBtn;
    PauseButton.guiTexture.texture = PauseBtn;
    PauseMenu.gameObject.SetActiveRecursively(false);
}

it resumes the game but with time.timescale = 0.1f only … any ideas

yield WaitForSeconds ( 3 ) ; // Just don’t add it to Update. Use a co-routine.

I already solved it thanks :

void Awake(){
first = 0;
second = 0;
third = 0;
resumeIn3Seconds = false;
}

	void Update()
	{
		ResumeIn3Seconds();
	}
	
	void ResumeIn3Seconds(){
		if(resumeIn3Seconds){
			Counter123.active = true;
			StartCoroutine(ResumeAfterSeconds(3));
		}
	}
	   	
	private IEnumerator ResumeAfterSeconds(int resumetime) // 3
	{
	    Time.timeScale = 0.0001f;
	    float pauseEndTime = Time.realtimeSinceStartup + resumetime; // 10 + 4 = 13
		
		float number3 = Time.realtimeSinceStartup + 1; // 10 + 1 = 11
		float number2 = Time.realtimeSinceStartup + 2; // 10 + 2 = 12
		float number1 = Time.realtimeSinceStartup + 3; // 10 + 3 = 13
		
	    while (Time.realtimeSinceStartup < pauseEndTime) // 10 < 13
	    {
			if(Time.realtimeSinceStartup <= number3)      // 10 < 11
				Counter123.guiTexture.texture = Three;
			else if(Time.realtimeSinceStartup <= number2) // 11 < 12
				Counter123.guiTexture.texture = Two;
			else if(Time.realtimeSinceStartup <= number1) // 12 < 13
				Counter123.guiTexture.texture = One;
			
	    	yield return null;
	    }
		Counter123.active = false;
		resumeIn3Seconds = false;
	        Time.timeScale = 1;
	}

Can’t you just pause the game and then Invoke a function to change the TimeScale value, 3 seconds later.

Something like this.

  void Update ()
    		{
    			// When you need to
    			pauseGame ();
    			Invoke("pauseGame",3.0f);
    		}
    		
		void pauseGame ()
		{
			if(Time.timeScale == 1f)
				Time.timeScale = 0f;
			else Time.timeScale = 1f;
		}