Create custom Bolt visual scripting node (unit) from script

I would like to create a custom unit with properties. Currently, I can do this by creating a method in a MonoBehavior and then selecting the method from the flow graph manually.

public class GS_Bolt_Setting : MonoBehaviour 
{
...
  public void Variable(string type, string name)
  {
  }
}

This displays the unit with a type and a name174509-capture.png

Is there a way to create this unit automatically from script?

In your Project Assets window, create a C# script and paste the following. After saving and returning to Unity from your editor, it should compile automatically and be added to the list of Nodes in Fuzzy Finder.

using System;
using Unity;
using UnityEngine;
using Unity.VisualScripting;

[IncludeInSettings(true)]
[UnitTitle("Mult3")]
[UnitSubtitle("Multiply A x B x C")]
[TypeIcon(typeof(Multiply<float>))]

public class Mult3 : Unit
{
   [DoNotSerialize] public ControlInput inTrigger;
   [DoNotSerialize] public ValueInput inA;
   [DoNotSerialize] public ValueInput inB;
   [DoNotSerialize] public ValueInput inC;
   
   [DoNotSerialize] public ControlOutput outTrigger;
   [DoNotSerialize] public ValueOutput outA;

   private float result;

   protected override void Definition()
   {
       inTrigger = ControlInput("", (flow) =>
       {
           result = flow.GetValue<float>(inA) * flow.GetValue<float>(inB) * flow.GetValue<float>(inC);
           return outTrigger;
       });
       
       outTrigger = ControlOutput(""); 
       
       inA = ValueInput<float>("A");
       inB = ValueInput<float>("B");
       inC = ValueInput<float>("C");
              
       outA = ValueOutput<float>("A x B x C", (flow) => result);

       Requirement(inA, inTrigger);
       Requirement(inB, inTrigger);
       Requirement(inC, inTrigger);
       Succession(inTrigger, outTrigger);
       Assignment(inTrigger, outA);
   }
}

Here is the official Unity documentation, which will help you customise my template. I have found that it’s sometimes necessary to Regenerate Nodes in Project Settings > Visual Scripting.

You may prefer to remove the TypeIcon line or replace it with another icon (most icon names are obvious).

Feel free to ask away!

How to create condition unit like IF ?
I want to create unit for check existing item in inventory by id.