Player Prefs Plus Plus

NOTE: PlayerPrefs++ is a free plugin for MBS Core. See here for more info on MBS Core

PlayerPrefs++ is a replacement for the default Unity PlayerPrefs class and offers a few enhancements to the class.

How to use PlayerPrefs++

To update your existing projects to use PlayerPrefs++, simply find each instance of PlayerPrefs in your code and prepend “mbs” to it. That is all. your project is now updated.

Example of your current code:

	PlayerPrefs.SetString("Name", "John");

Example of your new code:

	mbsPlayerPrefs.SetString("Name", "John");

Note when fetching a string from a category you need to provide a default return value or else you need to use mbsGetStringCat to fetch the string. This is only applicable to strings and only when stored under a category.

Enhancements to PlayerPrefs

As mentioned above, PlayerPrefs++ offers a couple of enhancements to the standard PlayerPrefs.

Firstly, PlayerPrefs++ allows you to save:

string, int, float, bool, Vector2, Vector3, Rect, Quaternion and Color.

Secondly, PlayerPrefs++ allows you to save your PlayerPrefs into categories.

This means you can easily delete a bunch of preferences with a single line of code while leaving all the rest in tact. To specify a category simply add the category name to the end of the function as a final parameter. That simple.

Example use:

void UpdateGrades(string student_id)


//get the previous semester's preferences...


name = mbsPlayerPrefs.GetString   (student_id+"Name"),

math = mbsPlayerPrefs.GetStringCat(student_id+"Math", "current"),

sci  = mbsPlayerPrefs.GetStringCat(student_id+"Science", "current"),

hist = mbsPlayerPrefs.GetStringCat(student_id+"History", "current");


average  = mbsPlayerPrefs.GetFloat(student_id+"ave", 0.0f);



passed = mbsPlayerPrefs.GetBool(student_id+"Passed", "current");


hair_color = mbsPlayerPrefs.GetColor(student_id+"hair");

//store the old prefs to a new category...

mbsPlayerPrefs.SetString(student_id+"Name", name);

mbsPlayerPrefs.SetString(student_id+"Math", math, "First semester");

mbsPlayerPrefs.SetString(student_id+"Science", sci, "First semester");

mbsPlayerPrefs.SetString(student_id+"History", hist, "First semester");

mbsPlayerPrefs.SetFloat (student_id+"ave", average, "First semester");

mbsPlayerPrefs.SetBool  (student_id+"passed", passed, "First semester");


//give a bonus to blonds...

if (hair_color == Color.white)

	average == 4.0f;


mbsPlayerPrefs.SetFloat(student_id+"ave", average);



void ClearOldGrades()


//remove all the previous preferences...




void CommitACrimeAgainstHumanity()


//completely destroy the entire school's database...