Code Generator for Playmaker creates custom Actions to access BGDatabase data (many fields are supported, but not all the fields)

Apart from Code Generation, you can use Playmaker's GetProperty and SetProperty actions with Generated MonoBehaviour to get/set any property from GameObject, hooked up to database.

Supported custom actions

With custom actions you have full control over database data- you can select/add/update/delete rows. Custom actions are generated for each table
# Action Description
1 GetByIndex Retrieve field values from database by row's 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

Supported fields

Database Field Playmaker Field Comments
int FsmInt
float FsmFloat
bool FsmBool
string FsmString
color FsmColor
rect FsmRect
vector2 FsmVector2
vector3 FsmVector3
quaternion FsmQuaternion
relationSingle FsmInt Playmakers int field stores the index of related row, or -1 if field is not set
relationMultiple FsmArray[int] Playmakers int array field stores the related rows array of indices
nested FsmArray[int] Just like relationMultiple, but read only
GameObject FsmGameObject Prefab asset, field is readonly
Object FsmObject Any Unity asset, field is readonly
Material FsmMaterial Unity material asset, field is readonly
Texture FsmTexture Unity texture asset, field is readonly
AudioClip FsmObject Unity audio asset, field is readonly
Font FsmObject Unity font asset, field is readonly
Texture2D FsmObject Unity texture2D asset, field is readonly
Sprite FsmObject Unity sprite asset, field is readonly
Sprite[] FsmArray Unity sprite array asset, field is readonly

If field type is not supported, it will be omitted

How to generate

Open BGDatabase window Window->BGDatabase

Go to Settings tab, and chose Playmaker

Fill parameters and press Generate button


Link Description
BGDatabasePlaymakerMin.cs Minimalistic example with single table and single name field
BGDatabasePlaymakerMax.cs Single table with all supported fields.