Mad Level Manager gives you great control over saving & loading your game with ability to create multiple player profiles. These options are available using MadLevelProfile class.
Saving and loading is done constantly when something changes using the API. Think about saves as of book of memories. Each time something new happens you write a memo into this book. You can write into it constantly, so player can go back to the place he left the game.
All saving and loading is based on properties. Properties are key-value pairs that you can set for each level or profile-scoped. For example profile-scoped will be player name, but for each level probably you’ll want to set highest score achieved. Properties can be saved with these types:
Each of these types have appropriate getrers and setters defined in MadLevelProfile class.
Save & Load system is strongly integrated with level select screens*. Each level has properties like locked, completed or may contain something custom like collected stars. You can set these properties easily and the saved state will be automatically loaded and displayed on level select screen.
Normally you can store any number of properties for your levels, but decide that only few of them will have representation on level select screen. You can define these properties for your icon prefab and in result it will look similar to this:
Remember that all of these properties are boolean type, and you should use MadProfile.SetLevelBoolean() method to change them. For instance if I want to gain first star for my Level 1 I must to write something like this:
MadLevelProfile.SetLevelBoolean("Level 1", "star_1", true);
Or if you are in Level 1 already you can:
MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
Note
Notice that all level names in the Hierarchy are equal to level names defined in your level configuration.
Warning
Property object names must be equal to stored property names, be careful to do not make a typo here!
By default there is profile called default, so if you don’t need to create more profiles this one will work fully transparent.
MadLevelProfile.RegisterProfile("MyProfileName");
Will also remove all progress information.
MadLevelProfile.UnregisterProfile("MyProfileName");
MadLevelProfile.profile = "MyProfileName";
Debug.Log("Current profile is " + MadLevelProfile.profile);
Debug.Log("Existing profiles: " + MadLevelProfile.profileList);
(Only if level icon has star_1 property)
MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);
MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);
MadLevelProfile.SetCompleted("Level name to unlock", true);
MadLevelProfile.SetLevelInteger(MadLevel.currentLevelName, "top score", 9999);
int topScore = MadLevelProfile.GetLevelInteger(MadLevel.currentLevelName, "top score");
MadLevelProfile.SetProfileString("player name", "Suzane");
string playerName = MadLevelProfile.GetProfileString("player name");
You probably will be interested in full MadLevelProfile API reference.