Setup

Create your own database

This step is required!
  1. Import the package
  2. Create your own database. Open Window->BGDatabase. Select Settings-> Main->Create new database tab. Chose the loader (Resources or StreamingAssets), fill in fields and press Create button
    empty database will be created at specified location
  3. Go to Configuration and create table (called Meta)
  4. Add fields
  5. Go to Database and create data for tables (called Entities)
No further action is required. Read further below only if you wish to know more details.

Which loader to chose?

Currently, Localization addon supports Resources loader only
  • 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.

Resources StreamingAssets Custom
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
  1. WEBGL requires custom loader
  2. Not supported by Localization addon
  1. you need to implement code, which loads database content.
  2. You need to load and assign database content using BGRepo.SetDefaultRepoContent method before accessing it
  3. Not supported by Localization addon
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
  1. Move bansheegz_database.bytes file into any location in your project using Unity Editor.
  2. Switch to file explorer, find bansheegz_database.bytes.meta file open it in text editor and paste the following guid to it 3637ea689da0cff4b8d5c0fb5d609c15
  3. Switch back to Unity and click on Reload button in BGDatabase window. Settings->Main>Database files->Database Loader should switch to Custom
  4. Implement the code, which loads database file and once it's loaded, call BGRepo.SetDefaultRepoContent(content) method (otherwise database will not be loaded)

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.

  1. Database file, named bansheegz_database.bytes should be placed right under Resources or Assets/StreamingAssets folder. Resources folder can be anywhere in your project but not under Editor folder.
  2. 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.
Settings file may contain sensitive information, so it's not recommended to keep it public

Reverting database to default (example) database

By default, BGDatabase uses default database, located at Assets\BansheeGz\BGDatabase\Examples\Resources\bansheegz_database_default.bytes 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 Reload button.