Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unity PlayerPrefsExtra gives you the ability to save more complexe data types such as : Vectors, Bool, Colors, Lists, ... and it uses the Unity's PlayerPrefs behind the scene.

License

Notifications You must be signed in to change notification settings

herbou/UnityPlayerPrefsExtra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

29 Commits

Repository files navigation

Unity PlayerPrefsExtra

Video thumbnail

Unity PlayerPrefsExtra gives you the ability to save more complexe data types such as : Vectors, Bool, Colors, Lists, ... and it uses the Unity's PlayerPrefs under the hood.

!? How to use :

Use the same syntaxe as PlayerPrefs.

しかく Booleans :

//Load
bool b = PlayerPrefsExtra.GetBool("mybool", false);
//Update (flip value)
b = !b;
//Save
PlayerPrefsExtra.SetBool("mybool", b);

しかく Vectors ( Vector2, Vector3, and Vector4 ):

//Load
Vector2 v = PlayerPrefsExtra.GetVector2("myV2", Vector2.zero);
//Update
v+=Vector2.one;
//Save
PlayerPrefsExtra.SetVector2("myV2", v);

しかく Colors :

// Get color
Color c = PlayerPrefsExtra.GetColor("Col");
// Set color
PlayerPrefsExtra.SetColor("Col", Color.red);

しかく Quaternions :

// Get Quaternion
Quaternion qua = PlayerPrefsExtra.GetQuaternion("q");
//Set Quaternion
PlayerPrefsExtra.SetQuaternion("q", qua);

しかく Lists :

// Get List
List<float> list = PlayerPrefsExtra.GetList<float>("myList", new List<float>());
// Add data to List
list.Add(Random.Range(100,900);
// Save List
PlayerPrefsExtra.SetList("myList", list);

しかく Objects :

//Class
[System.Serializable]
public class Shape{
	public int totalPoints = 3;
	public float strokeWidth = 0f;
	public List<Vector3> points = new List<Vector3>();
}
// Get object
Shape s = PlayerPrefsExtra.GetObject<Shape>("myShape", new Shape());
// Update object data
s.strokeWidth++;
s.points.Add(Vector3.one*Random.Range(0f,3f));
// Save object
PlayerPrefsExtra.SetObject("myShape", s);

しかく Delete All Keys (both PlayerPrefs & PlayerPrefsExtra) :

use PlayerPrefs instead of PlayerPrefsExtra

PlayerPrefs.DeleteAll();

しかく Delete one key :

use PlayerPrefs instead of PlayerPrefsExtra

PlayerPrefs.DeleteKey("Key");

しかく Check key existance :

use PlayerPrefs instead of PlayerPrefsExtra

PlayerPrefs.HasKey("Key");




❤️ Donate

Paypal

About

Unity PlayerPrefsExtra gives you the ability to save more complexe data types such as : Vectors, Bool, Colors, Lists, ... and it uses the Unity's PlayerPrefs behind the scene.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /