Sorry to bother with it, But I have yet to find a solution.
When you create a room number one variable to impose one variable(at Twin by two, etc.) And when I turn off the game and the resumption of the power will still be saved. Then when I load the menu changes with the load and load level by the number of (variable)
Sorry, but I don’t understand what you’re asking. Was there a question in there somewhere?
I’ll try it differently. I want to Save and Load, Which Will Retrieve Only levels:) That was on top of such theories as it possibly could.
If you want to save and load data you should look at using PlayerPrefs
is there any example?
Save script
function Update () {
print (PlayerPrefs.GetInt("leveliii"));
Application.LoadLevel (leveliii);
}
Load Script
function Update () {
PlayerPrefs.SetInt("leveliii", 1);
}
Will it work?
Sorry, I’m not quite sure what your trying to save
Are you trying to save which level the player is on? Or the whole level?
level the player is on
Ok then, the simplest way is to save and load the level by name.
For saving you want:
PlayerPrefs.SetString("PlayerSave", Application.loadedLevelName);
This will save the name of the current scene (the last scene to be loaded) to the PlayerPrefs location, under the key name PlayerSave
And to load it:
var LoadName = PlayerPrefs.GetString("PlayerSave");
//Check the data is valid
if (LoadName != "")
Application.LoadLevel(LoadName);
This will load the PlayerSave key we saved, then if the data is valid, we use it to load the scene with that name.
You won’t want to put this in an update loop, but instead they need to be called at specific times. This is usually done from a GUI, or when you complete the objective for your level (reach the end of it etc.)
My script:
function OnGUI () {
GUI.Box (Rect (10,10,120,90), "Game Menu");
if (GUI.Button (Rect (20,40,80,20), "Save")) {
PlayerPrefs.SetString("PlayerSave", Application.loadedLevelName);
}
if (GUI.Button (Rect (20,70,80,20), "Load")) {
if (LoadName != "")
Application.Load(LoadName);
}
if (GUI.Button (Rect (20,100,80,20), "Restart")) {
Application.LoadLevel (0);
}
}
My errors:
Oops, I made a mistake when I typed the load. Sorry about that. This works for me:
var LoadName = "";
function OnGUI () {
GUI.Box (Rect (10,10,120,90), "Game Menu");
if (GUI.Button (Rect (20,40,80,20), "Save")) {
PlayerPrefs.SetString("PlayerSave", Application.loadedLevelName);
}
if (GUI.Button (Rect (20,70,80,20), "Load")) {
LoadName = PlayerPrefs.GetString("PlayerSave");
if (LoadName != "")
Application.LoadLevel(LoadName);
}
if (GUI.Button (Rect (20,100,80,20), "Restart")) {
Application.LoadLevel (0);
}
}
What I do not see any button.
Do you see any of the GUI when you play the game? The menu you placed should be in the top left of the screen. Do you have other GUI covering it?
weirdly I found this and i needed this! finally i can save my
game!!! something i tought would never happen!!! THANKS ALOT!!!