PlayerPrefsPlus

This asset was formerly known as PlayerPrefs__X__ but was changed to PlayerPrefs__Plus__ as another asset with the same name came to our attention, sorry for any inconvenience caused

Hi Everyone,

PlayerPrefsPlus is a simple extension to unity that allows you to store a larger range of data types. Instead of just the usual Int, Float and Strings available to be saved PlayerPrefsPlus allows you to save Booleans, Vector2, Vector3, Vector4, Quaternions and Colors. The interface is as similar as we could get it to the standard PlayerPrefs so using it couldn’t be easier!

//Usually you'd save using PlayerPrefs with code like this:
PlayerPrefs.SetString("ExampleString",stringToSave);
//So we made sure with PlayerPrefsPlus you can save like this:
PlayerPrefsPlus.SetVector3("ExampleVector3",vector3ToSave);

//Loading is just as easy! Just use:
loadedQuaternion = PlayerPrefsPlus.GetQuaternion("ExampleQuaternion")
//And we've even included the optional Default values:
loadedColor = PlayerPrefsPlus.GetColor("ExampleColor",Color.grey)

PlayerPrefsPlus is written in both Javascript and C# and includes demos for both so you can continue with whichever language you prefer. :slight_smile:

This asset is available on the asset store for free (click here) and if you need another datatype to be stored just email us on assets@ninjapokestudios.net76.net or leave a comment here and we’ll try to sort it as soon as possible :slight_smile:

-The Ninjapoke studios team

PlayerPrefsX already exists and is well-known; I’d suggest a different name to avoid confusion.

–Eric

Thats annoying…
I really wish I’d have found that before I wrote the code…

I guess changing the name to avoid confusion is probably best; this also adds debate to whether I continue development of the array storing addition I was working on though…

On the plus side mine saves Vector4s unlike the other one :stuck_out_tongue: (not that I’ve even used a Vector4…)

Thanks for raising that,
Jamster

We’re in the process of changing the asset name to PlayerPrefsPlus after the other asset was flagged to us, if a moderator sees this could they change the thread name to the new name please? :slight_smile:

Also be warned the above link may not work for a short time whilst the asset changes name on the store, sorry for the inconvenience :?

-The Ninjapoke studios team

I’m not sure I have either, which is the main reason PlayerPrefsX doesn’t have it, but it’s trivial to add:

static function SetVector4 (key : String, vector : Vector4) : boolean {
	return SetFloatArray(key, [vector.x, vector.y, vector.z, vector.w]);
}
 
static function GetVector4 (key : String) : Vector4 {
	var floatArray = GetFloatArray(key);
	if (floatArray.Length < 4) {
		return Vector4.zero;
	}
	return Vector4(floatArray[0], floatArray[1], floatArray[2], floatArray[3]);
}

static function GetVector4 (key : String, defaultValue : Vector4) : Vector4 {
	if (PlayerPrefs.HasKey(key)) {
		return GetVector4(key);
	}
	return defaultValue;
}

There, now it saves Vector4. :wink:

OK.

–Eric

Noooo now my asset has no benefits! :stuck_out_tongue:

Thanks for the name change :slight_smile:

-Jamster