x


Anyway to save which seen the player was on, then load that scene back from another one at a different time?

I need unity to remember which scene i was playing before i quit, and then load it back hen i run the game again from a different scene- how do I do this?

more ▼

asked Oct 20 '10 at 08:10 PM

Fishman92 gravatar image

Fishman92
2.4k 101 113 128

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Have a look at the PlayerPrefs class - http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.SetInt.html

something like this should do the trick:

Set the player level when a new scene is loaded to save the number of the last level to be loaded on the player's machine:

PlayerPrefs.SetInt("SaveLevel", Application.loadedLevel);

And call this when the game is first started to get that same value:

savedLevel = PlayerPrefs.GetInt("SaveLevel"));
more ▼

answered Oct 20 '10 at 10:42 PM

chief1234 gravatar image

chief1234
368 13 14 26

Wow, thanks a bundle!! :D

Oct 20 '10 at 10:57 PM Fishman92

Glad I could help - please check the question as answered :)

Oct 21 '10 at 11:14 PM chief1234
(comments are locked)
10|3000 characters needed characters left

hi, may i aske? how do i declare savedLevel?

more ▼

answered Jul 28 '12 at 07:51 AM

shasha gravatar image

shasha
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x719
x438
x437
x322

asked: Oct 20 '10 at 08:10 PM

Seen: 855 times

Last Updated: Jul 28 '12 at 07:51 AM