Runtime usage

To use Databox at runtime simply make sure to have a reference to a Databox object.

You can register a method to the OnDatabaseLoaded event, which will be called when your database has been loaded.

Namespace

 using Databox;

Loading

  using Databox;
  public class Example : MonoBehaviour
  {
    // The reference to your databox object
    public DataboxObject data;
    
    void OnEnable()
    {
        data.OnDatabaseLoaded += DataReady;
    }
    
    void OnDisable()
    {
        data.OnDatabaseLoaded -= DataReady;
    }
    
    void Start()
    {
        data.LoadDatabase();
    }
    
    void DataReady()
    {
        // Access data
    }
  }

Saving

Get Data

GetData returns a reference of the data in the database. This means that, when changing the health value in the example you won't need to put the changed value back to the database as it gets updated automatically.

AddData

To add data by script simply call AddData.

OnValueChanged

Each data value has a "on value changed" event which gets called if a value has been changed.

Last updated