Author Topic: Pause/Resume Game  (Read 8377 times)

noporcru

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Pause/Resume Game
« on: February 20, 2014, 04:17:49 PM »
Okay so I made an NGUI pause menu.  I made it it's own scene separate from the game and main menu scene.  When in game scene, if the player presses "P" I set Time.timeScale to 0 and I use Application.LoadLevel ("PauseMenu") to go to my pause menu.  I feel like that is wrong since now I can't figure out how to resume my game from where I paused since I exited the scene and would have to re-enter my game scene.  So would I have to remake the Pause Menu in the game scene and somehow hide it until I press "P"? I'm not really sure how to go about doing it (I'm fairly new to Unity and NGUI).  Also, I'm not sure if this makes a difference but I am using the free version for now (will definitely buy this awesome tool when I have funds). Oh, and thank you very much in advance to whoever can help or tries to help, it is very much appreciated.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pause/Resume Game
« Reply #1 on: February 21, 2014, 04:45:18 PM »
The free version is incredibly old and is not supported, so there isn't a whole lot I can do as to be honest I don't even remember if it supports what you're trying to do.

In the current version you can simply set timeScale to zero, and the UI will not be affected. You can still use NGUI tweens and they will work even though the game has been paused. UI is not affected by the time scale.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Pause/Resume Game
« Reply #2 on: February 23, 2014, 01:34:32 AM »
Don't load a new scene for a pause menu - just make the pause menu a prefab and put it on the screen while the game is in the background. Since you've set TimeScale to 0 the game should stand perfectly still.

You don't even need to load it until you need it. Look into http://docs.unity3d.com/Documentation/ScriptReference/Resources.Load.html and how you handle prefabs.

It's fairly simple.

noporcru

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Pause/Resume Game
« Reply #3 on: February 27, 2014, 11:54:19 PM »
Thanks for the answers guys I got it with tweens.