Video tutorial : https://youtu.be/wqRYdFcfiVw
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.
Use the same syntaxe as PlayerPrefs.
//Load
bool b = PlayerPrefsExtra.GetBool("mybool", false);
//Update (flip value)
b = !b;
//Save
PlayerPrefsExtra.SetBool("mybool", b);
//Load
Vector2 v = PlayerPrefsExtra.GetVector2("myV2", Vector2.zero);
//Update
v+=Vector2.one;
//Save
PlayerPrefsExtra.SetVector2("myV2", v);
// Get color
Color c = PlayerPrefsExtra.GetColor("Col");
// Set color
PlayerPrefsExtra.SetColor("Col", Color.red);
// Get Quaternion
Quaternion qua = PlayerPrefsExtra.GetQuaternion("q");
//Set Quaternion
PlayerPrefsExtra.SetQuaternion("q", qua);
// 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);
//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);