Best way to save data in Unity game

messedupsongguy picture messedupsongguy · Dec 23, 2015 · Viewed 56.9k times · Source

I was wondering... What's the best way to save data in Unity games. JSONs? If so, how? Thanks

Answer

Muhammad Faizan Khan picture Muhammad Faizan Khan · Dec 23, 2015

Here are some of the different Ways and Methods to Save data for Unity Projects:

  1. Platform-Independent: One way of saving data in Unity3D in a Platform-independent way is to use the PlayerPrefs class. (Learn More 1, 2). PlayerPrefs is a static class and it is very easy to use but not reliable.

  2. PERSISTENCE - SAVING AND LOADING DATA using DontDestroyOnLoad, PlayerPrefs, and data serialization Video Tutorial by unity.

  3. Server Side: You can also use a Server for saving data (like a combination of PHP and MySQL Database). You can use it to save Score Data, user profile, etc., Learn More From Unity Wiki

  4. For saving the in-game data to a Hard drive in a format that can be understood and loaded later on, use a .NET/Mono feature known as Serialization. Learn More

  5. Simple JSON guide about Unity is available at Unity Wiki or officially you can see JSON serialization

  6. SQLite (an embedded database for your app) is another great option for you to get the Free Package, it is simple and easy (and my favorite) if you know SQL.

  7. Scriptable Object: its a data container. Useful for unchanging data. Suitable for large unchaning data and aamazing safe projects memory.

enter image description here

The above is taken from my blog post on Data Saving Techniques for Unity3d Applications.