2
\$\begingroup\$

Say, I have a GUI Menu attached in a game scene. The game will be in pause state by default. I did it by setting "Time.timescale=0.0f"; I want my game to unpause only when Play button clicked. My question is how to access game scene from the script? And, what I to write on "OnClick" event? Your any suggestion will be highly appreciated. Regards

\$\endgroup\$
2
\$\begingroup\$

"How to access game scene from the script?" If you want to load a game scene use LoadLevel as mentioned. If you want to set the value of Time.timescale on a button click use this. However, I would suggest implementing a fsm to handle various game states.

|improve this answer|||||
\$\endgroup\$
0
\$\begingroup\$

I'm not 100% sure of what is your problem. But what I understand is that you start your game with Time.timescale at 0 and whant a specific game object to be "unpaused" (ie. not affected by the Time.timescale property).

As far as I know it's not possible for a specific game object to use a different TimeScale value.

I'd suggest to implement and use your own Timer system for pause and not use timescale anymore. The idea is that all your game object could use their own timers (updated by Time.time / Time.deltatime provided by Unity), then you'd be able to pause and unpause any game object you want, independantly from the rest of the game.

I hope it helps.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.