Settings

"Settings" addon let you specify some parameters for database

Parameter name Description
Database asset format By default, data is serialized in binary format, but there is an option to use JSON instead
Do not use JSON format in final builds, cause it is much slower and uses a lot more memory (can be x10 and more)
You can use this package to auto-switch format from JSON to binary before building your app and back from binary to JSON after building is completed
Multithreaded loading "Multithreaded loading" can reduce the loading time if your database is big enough. How do I know if database is big enough? "Multithreaded loading" does not work with "Lazy Load" addon enabled.
Zipped content "Zipped content" means the database content is compressed before saving and decompressed before loading. It can reduce the size of the database, but loading/saving will take a little bit longer.
Encryptor class C# class, implementing BansheeGz.BGDatabase.BGEncryptor interface for encrypting/decrypting database data. More info
Encryptor config String config to be passed to Encryptor. Use it to create multiple versions of encryption algorithm
Encrypt SaveLoad addon data If this parameter is on, SaveLoad addon's data will also be encrypted.

Database data encryption

[We do not believe efficient encryption can be implemented, but we may be wrong, so we added interface for data encryption.]

To encrypt data:

  1. [Important] Back up your database files before setting encryptor
  2. Create your own C# class, implementing BansheeGz.BGDatabase.BGEncryptor interface. Use this implementation as an example
  3. [Important] Make sure that byte array after encrypting and decrypting is the same as initial (non encrypted) array
  4. Put this class to runtime assembly
  5. Once you encrypted the data- do not remove encryptor class - otherwise it would be not possible to decrypt the data
  6. Use encryptor config to change encryption algorithm. Do not remove obsolete algorithm, so the data, encrypted with old algorithm can still be decrypted.
  7. Set required parameters (Encryptor class/Encryptor config/Encrypt SaveLoad addon data) and save database.

How do I measure performance?

To measure the effects of "Multithreaded loading" and "Zipped content" on performance, you may want to benchmark the database loading time. This is how:

  1. Create an empty scene
  2. Create C# script, named BGDatabaseLoadingBenchmark.cs
  3. Copy/paste the content of BGDatabaseLoadingBenchmark.cs, which is listed below
  4. Add new GameObject to the scene and add BGDatabaseLoadingBenchmark.cs script to this GameObject
  5. Run the scene
  6. Loading time will be printed to the console

using UnityEngine;
using BansheeGz.BGDatabase;
public class BGDatabaseLoadingBenchmark : MonoBehaviour
{
    void Start()
    {
        BGUtil.Measure("Database loading", () =>
        {
            var repo = BGRepo.I;
        });
    }
}