Unity Visual Scripting (ex-Bolt)

Description

Code Generator for Unity Visual Scripting (ex-Bolt) creates custom Units to manage BGDatabase data.

All fields are supported (Unity asset fields are readonly, more info).

"Unity Visual Scripting" package is available for Unity version >= 2021 via Package manager (installed by default), Bolt is available for Unity 2018-2020 via Asset Store.

Step-by-step guide and example project

Step-by-step guide and an example project is available for download here

Restrictions

After you generated units and used them in your graphs - do not change code generator parameters or rename table/fields - otherwise you can lose their references in existing graphs

List of generated units

With custom units you have full control over database data - you can select/add/update/delete rows. Custom units are generated for each table
# Unit 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
10 Get by key Retrieve the row by using provided key values (for each key)
11 Find by index Find the rows by using provided index range (for each index)

How to generate

  • Open BGDatabase window Window->BGDatabase
  • Select Settings tab, and chose Visual Scripting (ex-Bolt)
  • Fill in parameters and press Generate button
  • After units was generated, you may need to update units database. If you use Visual Scripting, select Edit->Project Settings->Visual Scripting->Regenerate Units. If you use Bolt, select Tools->Bolt->Build Unit Options
Once you chose your naming scheme package + Classes name prefix/Field name prefix and used your generated units in Bolt's graphs, you should not change these settings, otherwise the references to these units will be lost. The same applies to tables/fields names.

Parameters

Parameter name Description
Code Generator Class to use for code generation (use default one)
Source file Source file to use for generated C# classes (units). 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 B_ prefix, the final class for MyTable table and GetById unit will be named B_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.
Target platform The choice between "Unity Visual Scripting" or "Bolt"

Difference between getters and setters

  1. Getters are not included into control flow: you can not include them. Values are fetched when requested.
  2. On the other hand, setters are required to be included into control flow, otherwise they will not be executed


Bolt to VisualScripting package migration guide

This guide is for database units/plugins only

  1. Re-generate units with VisualScripting platform as a target.
    Alternatively, open C# file with generated units for Bolt in your text editor and replace the following lines:
    using Bolt;
    using Ludiq;
    
    with this line:
    using Unity.VisualScripting;
    Save the file.
  2. If you use any additional Bolt plugins, download and import their VisualScripting versions from download page

Additional downloads

  1. Quick start example project
  2. Custom unit to support SaveLoad addon is available for free download here
  3. Custom unit to support unity assets loading from Addressables system is available for download here
  4. Alternative (generic) units for accessing database: link