In the Complete Unity Developer course, we are introduced to Playerprefs and expand the system by creating a Playerprefs manager class, which helps to keep things organized, but isn't any safer.
To make a safe class, we will use something called Serialization, and Binary Formatters, which are provided by Unity, and can easily be combined to make Saving Data easy!
Below is an example of such class:
*When implementing the code, do not forget of use the libraries System, System.Runtime.Serialization.Formatters.Binary, and System.IO!
You will declare any variables as you would do on any scripts. When the game starts, it will Load the Data. When the game ends, it will save the Data. (You would have to have a void OnDisable() where you call Save.)
We save the Data by serializing the InternalData class. You can see how this is done in both the Load and Save voids. We use the BinaryFormatter so the resulting file will be in Binary, and won't be easily hacked.
On those voids, you will make something similar as what is shown above, and all your information will be passed to the Data!
Another good thing to know, is that you can add ANY variable to the system, just by doing the exact same thing! Dictionaries, Arrays, Bools, and the SUPER IMPORTANT, VECTORS!!! You can even save a GameObject!
All you need here is creativity. You can do what you want with this. I personally keep this as a singleton, and have some data I do not save, but just use in between scenes, but you can do differently!
By the way, this system is not 100% safe, but should be enough for any small-medium game to be protected from lazy-hackers! It may help you save a few bucks! You can find the full code here!
Special thanks to Ben Tristem for the spectacular Unity course!
Much of what I learned came from there!
You can find the course at: http://www.udemy.com/unitycourse/
or at: http://www.completeunitydeveloper.com/
-------------------------------< The Code Starts Here >--------------------------------