Behavior

Description

Unity Behavior is a visual tool for authoring behaviors used to control non-player characters (NPCs) or objects.

Setup guide

Install Behavior package via Package Manager (Unity 6 is required)

To generate the actions for Unity Behavior, make sure you use BGDatabase version >= 1.8.13, select "Settings->Behavior", fill in parameters as shown on the screenshot below and press on Generate. "Source File" should point to a new, non-existent cs file, it will be overwritten each time you generate classes.

By default, the database actions can be found under Action/BGDatabase category

Once you chose your naming scheme package + Classes name prefix/Field name prefix and used your generated actions in Behavior's graphs, you should not change these settings, otherwise the references to these actions will be lost. The same applies to tables/fields names.

Which actions are generated?

Foe each table the following actions are generated

# Action Description
1 GetByIndex Retrieve field values from database by provided row's (physical) index. This is the best method to use inside for-each loop
2 GetById Retrieve field values from database by row's id.
3 GetByName Retrieve field values from database by row's name.
4 SetByIndex Set field values to database by row's index.
5 SetById Set field values to database by row's id.
6 SetByName Set field values to database by row's name.
7 Count Retrieve total number of rows
8 Create Create a new row
9 Delete Delete a row by its index
10 GetByKey For each key a separate node is generated. This node allows to get row(s) using key's fields values

How to use Get and Set actions

Each database field has 2 corresponding variables in Get/Set actions, one for the value itself and another one for a boolean flag, indicating that you want to get/set this value. To initialize value transfer, you need to
  1. Turn on the flag
  2. For "GetXXX" actions you also need to assign the variable to "field value" parameter