Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Database

pointcache edited this page Jan 16, 2017 · 4 revisions

Database is the backbone of all URSA Serialization.

Read also DatabaseTools

###Database concepts A Database in URSA is just a folder where your Entities are located. Without database entities are just prefabs with advanced functionality, with database assigned IDs, your entities are fully serializeable on runtime.

About philosophy: Typically Unity developer creates self containing prefabs that have graphics, sounds etc all loaded in one GameObject. Since URSA follows data driven approach where we think of Entity as purely data container, we can go further and think of database prefabs like that as well. If we imagine an entity that acts as data unit, without actually having Assets attached, but rather linked:

This prefab shows the ideology behind a database entry. It is an object description, meaning if we just drop it in scene it wont spawn graphics and other things, but that burden will lie on the systems that use it. Systems will spawn/destroy graphics based on current state of the object, i.e. While object is in inventory the worldPrefab and 3d representation (like weilded weapon) will not exist in scene, so this object will not have any performance impact, however it will exist as actual object in scene, and have data from prefab as well as serialized data. If we want to transfer this object from inventory of NPC, to the inventory of the player, we can just reparent it to player inventory. This is the paradigm - use gameobjects as data units by themselves.

Database:

  • Uses URSASettings to determine its work folders
  • Scans workfolders for all prefabs with Entity and assigns database_ID.
  • Creates DatabaseManifest file that helps with searches on runtime.
  • Has options in URSAMenu

TODO: Additionally database provides the means to perform advanced searches, like searching by Component , like :

string[] AllWeapons = Database.GetByComponent(typeof(Weapon));

foreach(var w in AllWeapons) {
   GameObject prefab = Database.GetPrefab(w);
}
Clone this wiki locally