I was wondering... What's the best way to save data in Unity games. JSONs? If so, how? Thanks
相关问题
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Easiest way to get json and parse it using JQuery
- Newtonsoft DeserializeXNode expands internal array
相关文章
- json_encode 没有把数组转为json
- Programmatically setting and saving the icon assoc
- Livy Server: return a dataframe as JSON?
- Omnisharp in VS Code produces a lot of warnings ab
- Unexpected end of JSON input from an ajax call
- Call non-static methods on custom Unity Android Pl
- How do I do a nested list (array) of schema refere
- iconv() Vs. utf8_encode()
See my previous answer for a similar situation and a simple way to save data.
Short answer to your long question!
Here are some of the different Ways and Methods to Save data for Unity Projects:
Platform-Independent: One way of saving data in Unity3D in a Platform-independent way is to use the PlayerPrefs class. (Learn More 1, 2).
PERSISTENCE - SAVING AND LOADING DATA using DontDestroyOnLoad, PlayerPrefs, and data serialization Video Tutorial by unity.
Server Side: You can also use a Server for saving data (like combination of PHP and MySQL Database). You can use it to save Score Data, user profile etc., Learn More From Unity Wiki
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
Simple JSON guide about Unity is available at Unity Wiki or officially you can see JSON serialization
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.
You can use many assets that are available for free and paid in asset store.
Save Game Free - XML and JSON saving and loading.
Syntax:
Example:
Save Game Pro - Binary saving and loading. fast and secure. Easy to use.
Syntax:
Example:
If you want to store your data in server there is a simple way with PHP and MySQL. What you have to do is:
STEP 1:
Get what ever data you want from your server just in single string (code is below):
And note that you MUST SEPARATE ANY string you want with a ; or any thing that you are comfortable with that and remember that we going to use it in C# in Unity.
STEP 2:
Now you should get the data from your web like this (it will be a long string):
STEP 3:
Now go to the Unity and create a C# script and attached that to what ever object in your scene and open the script up, then use this kind of code to manipulate the data that you retrieved from your database:
STEP 4:
You just NOW retrieved data from database, check the image from unity console:
I made this for who that may be, like me, stuck in database problems!