Description
Graph editor allows to describe data processing algorithm as set of connected nodes, similar to Unity Visual scripting asset. This editor is not a generic visual scripting tool however, but rather focused on database data processing and relatively simple calculations.
Where it is used
# | Name | Description |
---|---|---|
1 | Calculated fields | Database fields, which calculate their values at the moment these values are requested |
2 | Action field | Like calculated fields, but it does not return value. Instead, it can change database values, create/delete rows. |
3 | Graph binder | Graph binder is a unit binder, which calculates the value to be injected using graph |
4 | LiveUpdate plugin | Graph editor can be used to calculate HTTP parameters and headers values for LiveUpdate plugin |
5 | Custom button text provider | Graph editor can be used to override cell button text for the fields with the button-based cell editor. |
6 | Cell color provider | Graph editor can be used to provide the color for the cell. |
How it works
- Use "Special/SetResult" node to pass the result of calculation
- Use "ByType" category to perform calculations for bool, string, int, float, enum and list types.
- Use "Database" category to perform operations on database - read/write field values, create/delete rows. Operations, changing database state, are available for "action" field only.
- Use "Reflection" category to read/write objects field/properties
- You can call another graph using "Special/Call calculated cell" and pass parameters to it using public graph variables
- To access current entity for calculated/action fields, use "Special/Get current entity" node.
- To access current Game Object for graph binder, use "Special/Get current GameObject" node.
Graph variables
Each graph can have multiple variables, which can be used during graph execution. Calculated and action fields can have a default graph (shared between all rows if not overridden)- and if this default graph has public variables - these variables can be overridden for each row. So each row can use the same shared default graph- but with different public variable values. Here is an example - lets say you have a Items table with int "value" field, which can have some additional buff and debuff values and the final value is calculated as value+buff-debuff. In this case you can have this default graph with 2 public variables: and override variable values for each row if needed Also, the better alternative exist in this case - you can just add "buff" and "debuff" fields to the database and use database values instead of variables. So using public variables to customize data calculation for specific rows is advised only if it's not possible to replace variables with database fields.Nodes reference
Folder | Subfolder | Nodes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ByType | This folder has wrapper methods on top of C#/Unity API mostly. | ||||||||||||
bool | And | Or | Or exclusive | Negate | Bool parse | ||||||||||||
enum | Enum literal, Enum convert (cast enum to int), | ||||||||||||
float | Float literal | Float add | Float subtract | Float multiply | Float divide | Approximately | Ceil | Ceil to int | Floor | Floor to int | Float modulo | Float parse | Pow | RoundToInt | Sqrt | | ||||||||||||
float/comparisons | Float equal | Float greater | Float greater or equal | Float less | Float less or equal | | ||||||||||||
float/constants | Epsilon constant | Infinity constant | NegativeInfinity constant | NaN constant | PI | | ||||||||||||
float/trigonometry | Acos | Asin | Atan | Atan2 | Cos | Deg2Rad | Rad2Deg | Sin | Tan | | ||||||||||||
int | Int literal | Int add | Int subtract | Int multiply | Int divide | Int modulo | Int parse | ||||||||||||
int/comparison | Int equal | Int greater | Int greater or equal | Int less | Int less or equal | ||||||||||||
list | List add | List addRange | List clear | List contains | List count | Create list | List get | List indexOf | List insert | List remove | List removeAt | List set | | ||||||||||||
object | Cast | Change type | Equal | IsNull | NotEqual | null literal | Object to string | | ||||||||||||
string | String add | IndexOf | IsNullOrEmpty | String join | String length | Split | Substring | Substring2 | ToLower | ToUpper | Trim | | ||||||||||||
Database |
|
||||||||||||
Generic/meta |
|
||||||||||||
Generic/field |
|
||||||||||||
Generic/entity |
|
||||||||||||
Generic/cell |
|
||||||||||||
Flow |
|
||||||||||||
Reflection |
|
||||||||||||
Special |
|
||||||||||||
Unity |
|
||||||||||||
Variables |
|
||||||||||||
Localization | Meta [MetaName] | "Get localized value" - returns localized value. Node is added for each singleValue localization table. This node requires a localization addon | |||||||||||
|
Graph specifications
Name | Value | Comment |
---|---|---|
Maximum number of nodes | 255 | |
Maximum number of ports (per node) | 255 | |
Maximum number of graph variables | 255 | |
Maximum number of iterations (for "For" and "While" nodes) | 10000 |
Creating a custom node
Here is en example custom node for "A+B-C" expression.
using BansheeGz.BGDatabase;
[BGCalcUnitDefinition("Custom/Add remove int")]
public class AddSubtractUnit : BGCalcUnit
{
private BGCalcValueInput a;
private BGCalcValueInput b;
private BGCalcValueInput c;
public override void Definition()
{
a = ValueInput<int>( "A", "a");
b = ValueInput<int>( "B", "b");
c = ValueInput<int>( "C", "c");
ValueOutput<int>("A+B-C", "d", GetValue);
}
private int GetValue(BGCalcFlowI flow)
{
return flow.GetValue<int>(a) + flow.GetValue<int>(b) - flow.GetValue<int>(c);
}
}
And here is an example of using this node in the graph
Use the source code package for more nodes example (search for source files, starting with BGCalcUnit prefix)