-
Notifications
You must be signed in to change notification settings - Fork 5
Serialization
It is based on the idea that everything in the game is a prefab. By knowing the prefab id, we can represent entities as that id.
Serialization in URSA:
- Saves entities transform info, as well as parenting (only to other entities and components, not gameobjects)
- Saves components data located in their SerializedData
Since Entity is a abstracted composition of GameObjects and components, the need for parenting woes is reduced, thus URSA encourages you not to create complex hierarchical logic, but rather use hierarchy for scene organizational purposes, and "container" logic, like inventories, modular objects etc.
All serialization (with exception of Configs) happens in SaveSystem. It is responsible for saving scene state, PersistentData state and Bluerpints
When saving we use this data structure:
- SaveObject
- EntityObject
- CompRefs
- ComponentObjects
When serializing we collect all objects of interest and create a specialized data storage middleman for each type. We store them remembering id's of their parents. We store SerializedData from components as well.
EntityObject describes the root entity:
public class EntityObject
{
public string database_ID;
public string instance_ID;
public string blueprint_ID;
public string parentName;
public string gameObjectName;
public bool parentIsComponent;
public bool parentIsEntity;
public string parent_entity_ID;
public string parent_component_ID;
public Vector3 position;
public Vector3 rotation;
public Vector3 scale;
}Since Entity is nothing but a locator, or a root object all we need to know about it is: