Description
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 (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 |
11 | FindByIndex | For each index a separate node is generated. This node allows to get row(s) by using between operator, accepting min and max values. |
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 | |
enum | FsmEnum | |
enumShort | FsmEnum | |
enumByte | FsmEnum | |
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 |
objectReference | BGWithId | Readonly. BGWithId is Unity component(Object) |
objectListReference | FsmArray[Object] | |
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 |
List<bool> | FsmArray | List of bool. [ArrayEditor(VariableType.Bool)] attribute is added to Playmaker var |
List<int> | FsmArray | List of integers. [ArrayEditor(VariableType.Int)] attribute is added to Playmaker var |
List<float> | FsmArray | List of floats. [ArrayEditor(VariableType.Float)] attribute is added to Playmaker var |
List<string> | FsmArray | List of strings. [ArrayEditor(VariableType.String)] attribute is added to Playmaker var |
List<Color> | FsmArray | List of colors. [ArrayEditor(VariableType.Color)] attribute is added to Playmaker var |
List<Vector2> | FsmArray | List of vector2 values. [ArrayEditor(VariableType.Vector2)] attribute is added to Playmaker var |
List<Vector3> | FsmArray | List of vector3 values. [ArrayEditor(VariableType.Vector3)] attribute is added to Playmaker var |
If field type is not supported, it will be omitted
How to generate actions
Open BGDatabase window Window->BGDatabase
Select Settings
tab, and choose Playmaker
Fill parameters and press Generate
button
Once you chose your naming scheme package + Classes name prefix/Field name prefix
and used your generated actions in PLaymaker's state machines, you should not change these settings,
otherwise the references to these actions will be lost. The same applies to tables/fields names.
Hints
- If you plan to use Addressables system - avoid using
[
and]
symbols in your folders names, cause these symbols interfere with Addressables naming convention
Parameters
Parameter name | Description |
---|---|
Code Generator | Class to use for code generation (use the default one) |
Source file | Source file to use for generated C# classes (actions). All classes will be put into one single .cs file, which should be under your project folder |
Package | Package (C# namespace) for generated classes. For example MySpace . You can safely leave this setting blank. |
Class names prefix |
Prefix to use for each class name.
So if you use P_ prefix, the final class (action) name for MyTable table and GetById action will be P_MyTableGetById .
We have multiple code generators, so using different prefixes for different code generators helps to differentiate generated classes and avoid naming collisions
|
Field names prefix | Prefix to use for each generated property name. So if you use f_ prefix, the final name for intField field will be f_intField .
You can safely leave this setting blank.
|
Action category |
Playmaker's action category to put all generated classes (actions) in. Default is BansheeGz
|
Example
Link | Description |
---|---|
BGDatabasePlaymakerMin.cs | Minimalistic example with single table and single name field |
BGDatabasePlaymakerMax.cs | Single table with all supported fields. |
Additional downloads
- Custom actions to support SaveLoad addon is available for download here
- Custom action to support unity assets loading from Addressables system is available for download here