- Home /
Duplicate Question
Load and Save Scenes with PlayerPrefs.Set/GetInt
Hello. That i am trying to do is
When i win at 1 scene, i want to save it,
after if i close the PlayMode(Or my game) i want make it to Make Load Scene like Games saving the scene and if you want to continue the last Scene just select The scene and play. For Example :
I have 3 Scenes.
MainMenu Level1 Level2
I am start the game and i haven't play this game again to my Pc. i am pressing New Game I am playing Level1 scene and when i win (with an winnerScript) i set it to make PlayerPrefs save the last map i played.;
After i set it to go me at Level2 Scene. When i Finish i make it to Save data again.
that i want to fix are at main menu make the Scenes i had play and i can play Right now.
my Scripts(JavaScript) are as following: MainMenu:
private function loadProfFunc(id : int) {
if(PlayerPrefs.GetInt("Test", mapLevel) == 0) {
if(GUILayout.TextArea("You haven't Start Any Level."));
}
if(numberLoad == 1) {
if(PlayerPrefs.GetInt("Test",generalLevels.mapLevel) == 1) {
generalLevels.mapLevel = 1;
Application.LoadLevel(1);
}
}
}
generalLevels:
// This Code are to give the map a ID
public static var mapLevel = 0;
winnerPlayer:
function OnTriggerEnter(winner : Collider) {
if(winner.tag == "Player") {
generalLevels.mapLevel = generalLevels.mapLevel + 1;
PlayerPrefs.SetInt("Test", generalLevels.mapLevel);
}
}
That was all my Scripts(a part of Them)
How can i fix it? If there any problem what must to do? Is this way true for that i am trying to do? if no what way is better and how can i do it? If already exist a answer like this (just send me the link)
thank you for read me!
look at "Unity Serializer" everyone uses it, search
Also just FWIW, a detail. PlayerPrefs is not secure, so largely useless for real games.
I've taken to using "Secured PlayerPrefs" from the Asset Store. It's pretty good.
This has been asked too many times before. Here is a link: http://lmgtfy.com/?q=unity+load+save+scene Because I decide to be nice :)
Good point Ben if you do have the karma to close a question, just do so for sure
Follow this Question
Related Questions
carrying player data from one scene to the next 1 Answer
how to save a load a game? 1 Answer
Save game support, how do I load audio in a sertain time frame? 0 Answers
Save/Load/New 1 Answer