Doloro GDK 22 .1.0 Beta
by Tauri Interactive
|
DDM ST is a growing module that exists to simplify cross-session work with a data both in editor and during runtime.
Serialization process is a way to convert a runtime object to a data set that can be restored back to the same object using deserialization.
This useful at any stage of any development:
Stage | Case |
---|---|
Editor | Serialization of complex object and saving its data in binary arrays is an easiest way to work with custom editor solutions avoiding using of rough features of UnityEditor.SerializedObject and UnityEditor.SerializedProperty those have a lot of limits and tend to lose a changed data in any inaccurate way of use. |
Runtime | Serialization\Deserialization process is a most easy way to clone objects. |
Cross-session | Serialization\Deserialization is a most useful way to save \ load game session data avoiding manual streaming of a unstructured data to a file. |
The tool that allows to serialize/deserialize object in binary format.
Features:
Exmplore API: Doloro.DataManagement.Serialization.BinarySerializationTool
Implement to your class System.Runtime.Serialization.ISerializable
interface.
Send your object to the most suitable Doloro.DataManagement.Serialization.Serialize
method.
Following example demonstrates serialization process for the compatible object created by following instruction provided at the Create supportive class section.
The example works within runtime memory. But tool also allows you to work with streams and file system.
Member | Meaning |
---|---|
OBJ_TYPE | Type of the object that will be serialized. |
| ORIGIN_OBJ| | A serializable object. | | BINARY_DATA | A data array received represents the object in binary format. |
Send binary data path to the Doloro.DataManagement.Serialization.Deserialize
method and get decoded object.
Following example demonstrates deserialization process of the serialized object created at the Serialize (save data) step.
During source modification you may face incompatibility of serialized data with a new object structure.
By default, BST handles such compatibility issues automatically, but for advanced task you may like to handle the process manually.
BST leaves you a way to handle your data as you wish. For this during deserialization you may add a
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
.
Binary formater using deserialization provided with following BinarySerializationTool
members.
object Deserialize(byte[] data, BinaryFormatter formatter)
object Deserialize(string fullPath, BinaryFormatter formatter)
object Deserialize(Stream stream, BinaryFormatter formatter)
You may find an example of BinaryFormatter
using at the official MS supplied documentation.