How to run Graph in C# Script ?

Lee 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 1

There is a FlowGraph does not attached to any gameobject, How can I run it?

just like this:

Macro macro = load("Asset/testMacro") as Macro

FlowGraph graph = new FlowGraph(macro)


in fact,I want to use Bolt with ECS

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):

Hi Lee,

Bolt is not compatible with ECS at the moment, because it is an entirely different coding paradigm that is still in preview.

If your macro is not attached to any game object, it will not get instantiated. But if you want to run it any way, like we do for Gizmo events in the editor, you can try the following:

var reference = GraphReference.New(myMacro, true);
reference.TriggerEventHandler(hook => hook.name == "Custom", new CustomEventArgs("CustomEventName"), parent => true, true);

This will trigger the custom event named "CustomEventName" in your macro.