filmov
tv
Storing Data (Objects & Lists) with JSON - Unity Tutorial 2021

Показать описание
In this tutorial you'll learn how to save and read data into JSON files. We focuse more on lists which needs a little bit more code than default objects, but the latter one is also explained.
JSON files store data in key-value pairs and are mainly used in web languages for communication between client and server, but it is also quite useful for games. Especially since Unity comes with a lightweight JSON serializer. This one unfortunately can natively only convert objects into JSON strings. But storing basic lists is also a very big part in games, e.g. for highscores. This tutorial acts as a preparation for my highscore list tutorial and uses this usecase. However the result is a generic FileHandler script, which can save and than read whatever you want.
It just lacks of file validation and error handling, which is not part of this video.
Explanation to (04:03):
StackOverflow Link (07:27)
=========
=========
Timestamps:
00:00 - Intro
00:23 - Setup Explanation
02:50 - Creating the FileHandler - Writing
03:40 - JSON Explanation
04:24 - Saving the Data
11:45 - Reading the Data
14:36 - Saving & Reading Single Objects
16:02 - Additional Information
JSON files store data in key-value pairs and are mainly used in web languages for communication between client and server, but it is also quite useful for games. Especially since Unity comes with a lightweight JSON serializer. This one unfortunately can natively only convert objects into JSON strings. But storing basic lists is also a very big part in games, e.g. for highscores. This tutorial acts as a preparation for my highscore list tutorial and uses this usecase. However the result is a generic FileHandler script, which can save and than read whatever you want.
It just lacks of file validation and error handling, which is not part of this video.
Explanation to (04:03):
StackOverflow Link (07:27)
=========
=========
Timestamps:
00:00 - Intro
00:23 - Setup Explanation
02:50 - Creating the FileHandler - Writing
03:40 - JSON Explanation
04:24 - Saving the Data
11:45 - Reading the Data
14:36 - Saving & Reading Single Objects
16:02 - Additional Information
Комментарии