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:

  • boolean
  • integer
  • float
  • string

Each of these types have appropriate getrers and setters defined in MadLevelProfile class.

Relation With Icons

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);
Notice that all level names in the Hierarchy are equal to level names defined in your level configuration.
Property object names must be equal to stored property names, be careful to do not make a typo here!

Common Workflow

MadProfile class is defined in MadLevelManager namespace, so don’t forget to put this at the top of your C# file:

using MadLevelManager;

Profiles

By default there is profile called default, so if you don’t need to create more profiles this one will work fully transparent.

Creating a New Profile

MadLevelProfile.RegisterProfile("MyProfileName");

Removing existing profile

Will also remove all progress information.

MadLevelProfile.UnregisterProfile("MyProfileName");

Getting/setting current profile

MadLevelProfile.profile = "MyProfileName";
Debug.Log("Current profile is " + MadLevelProfile.profile);

Listing existing profiles

Debug.Log("Existing profiles: " + MadLevelProfile.profileList);

Properties

Acquiring a current level star

(Only if level icon has star_1 property)

MadLevelProfile.SetLevelBoolean(MadLevel.currentLevelName, "star_1", true);

Completing current level

MadLevelProfile.SetCompleted(MadLevel.currentLevelName, true);

Unlocking selected level

MadLevelProfile.SetCompleted("Level name to unlock", true);

Getting/setting custom level property

MadLevelProfile.SetLevelInteger(MadLevel.currentLevelName, "top score", 9999);
int topScore = MadLevelProfile.GetLevelInteger(MadLevel.currentLevelName, "top score");

Getting/setting custom profile-scoped property

MadLevelProfile.SetProfileString("player name", "Suzane");
string playerName = MadLevelProfile.GetProfileString("player name");

More info

You probably will be interested in full MadLevelProfile API reference.