Create your own database
- Import the package
Create your own database.
Settings-> Main->Create new databasetab. Chose the loader (Resources or StreamingAssets), fill in fields and press
Configurationand create table (called Meta)
- Add fields
Databaseand create data for tables (called Entities)
Which loader to chose?
- Chose Resources loader, if you do not use Resources folders to store assets (Unity does not recommend to do it)
- Chose StreamingAssets if you have a lot of assets in the Resources folders or if you want to update database file without rebuilding the game
- Chose custom loader if you want to load database from custom location and do not mind to write your own loader
You can switch between Resources/StreamingAssets loaders by simply moving your database file between Resources/StreamingAssets folders.
|File location||under one of Resources folders||under Assets/StreamingAssets folder||anywhere in your project|
|Pros||Works everywhere without any extra effort||You can update database file without rebuilding your game||you can store your database file in any place under your project|
|Cons||If you store many assets under Resources folders (Unity does not recommend to do it), it may lead to slow database loading||
|How to enable||File bansheegz_database.bytes should be placed under one of Resources folders||File bansheegz_database.bytes should be placed under Assets/StreamingAssets folder||
Details about how database files are organized
There are 2 files BGDatabase operates with. The first file is the file with actual database data- it's shared among all users and it's available at runtime. The second file- is the file with user's settings- it's not available at runtime and it's not shared between users- each user has it's own settings.
Database file, named
bansheegz_database.bytesshould be placed right under Resources or Assets/StreamingAssets folder. Resources folder can be anywhere in your project but not under
Settings file (default name is
bansheegz_database_settings.json) has some additional information about database, like widths of the tables columns, data about Export/Import tasks etc. It can be placed in Resources folder next to database file, however it may contain sensitive data, so it's better be placed somewhere else. Go to Settings->Main to chose its path. Additionally, each user has it's own settings file. The path to this settings file is stored in EditorPrefs file. This also means, that settings file location is not transferable between different PCs and need to be chosen separately for each PC.
Reverting database to default (example) database
By default, BGDatabase uses default database, located at
As soon as you create your own database,
bansheegz_database.bytes file will be used as database.
But you may want to revert to default database temporarily, for example, to test how our example scenes are working.
This is very easy to do- locate your
bansheegz_database.bytes file (you can find it's location under
Settings->Main) and rename or move it to another location,
then return to
Window->BGDatabase and press
Reload button. (top left corner of BGDatabase window)
Default database will be loaded.
As soon as you do not need it anymore: rename your database file back to
bansheegz_database.bytes or move it back from another folder and press