카테고리 없음

Unity Xml Serialization Unity

schoosuradlis1976 2020. 3. 6. 17:17
  1. Unity Json Serialization
Unity Xml Serialization UnityUnity Xml Serialization Unity

This blog will cover the basics of serialization and the three most common methods of serialization in Unity: JSON, XML and Binary.Serialization is the process of converting an object into a form that can stored or transported easily.Objects are instances of classes and they are converted to a stream of bytes. This stream can then be stored as a file, saved onto a database or sent over internet to a web service.The reverse of this process, converting a stream which can be a file or a string into an object is called deserialization.

​It's easier to understand it using a simple example. In this example, the player details need to be saved, so that when the players replays the game, the details are already available to them. They don't need to provide it on every game session.When the player inputs his details into PlayerData object the state of the object is serialized and stored as a file. In the next play session the saved file is deserialized to recreate or clone the same state of our object. JSON and XML are two common standard serialization formats and both of them are shown in the image below. These standards have their own pros and cons and will be discussed later.

Saving Game DataSaving game related data like save files, entities data and game settings. Web Based ServicesUsing web based services like leaderboards, social features, facebook, twitter or google APIs. Separation of Data from Code ​Data can be separated from logic and it's easier for the designers to edit data files.

Serialization

Unity Json Serialization

Creating Levels ​Level Layouts, worlds and game scenarios can be saved in a compact form. Modding ​It is easier for modders to edit game entities or even add new entities or gameplay to your game.