How can i save 2 numbers at once in playerprefs?

Google up “store array in playerprefs” for tons of cheesy array storage scripts.

A better more-scalable approach might be to organize all your saved data into a single serializable structure, then turn it into a JSON string and write it out to a single PlayerPrefs string.

If you go this route, I highly suggest staying away from Unity’s JSON “tiny lite” package. It’s really not very capable at all and will silently fail on very common data structures, such as Dictionaries and Hashes and ALL properties.

Instead grab Newtonsoft JSON .NET off the asset store for free, or else install it from the Unity Package Manager (Window → Package Manager).

Also, always be sure to leverage sites like:

https://csharp2json.io

More info:

Load/Save steps:

An excellent discussion of loading/saving in Unity3D by Xarbrough:

2 Likes