Data Saving Techniques for Unity3d Application

Data is one of the integral elements in modern applications of Games, VR/AR, or gamification. Unity3d, the most famous and most widely use game engine provide you different options to save your game data in different ways. Once on a forum, a programmer asks the question that how to save data in unity3d?? and I  answered him with different options. I guess it is necessary to share the detail of the answer for future users. So, here is the list of different options for saving data for unity application. (we will like to update this article to add more techniques if you know anyone).




1. Platform-Independent:

One way of saving data in Unity3D in a Platform-independent way is to use the PlayerPrefs class. Here is the example to set a string and later get it through PlayerPrefs class.



Where the Data Store? Here is the chart:

Platform
Data stored at
Windows
Registry under HKCU\Software\[company name]\[product name] key
macOS
~/Library/Preferences folder, in a file named unity.[company name].[product name].plist, 
Win Phone 8
 application's local folder
WebGL
browser's IndexedDB
Linux
~/.config/unity3d/[CompanyName]/[ProductName]
Android
/data/data/pkg-name/shared_prefs/pkg-name.xml



* company and product names are the names set up in Project Settings

Reference Links:

·   PlayerPrefas Documentation

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

2. 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
You can also use third party solution like back4App and firebase.



3. Embedded Database:

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