📖
FlowReactor
  • 👋Welcome
  • Installation
  • Interface
    • Graph Library
    • Graph Explorer
  • FlowReactorComponent
  • Settings
  • Addons / Packages
  • Guides
    • Introduction
    • Create custom node
    • Variables & Blackboards
      • Type conversions
    • Using the EventSystem
      • Sequencing Events
  • In-depth
    • Node Attributes
    • Long running nodes
    • Node Modules
      • FRNodeControllable
      • FRNodeEventDispatcher
      • Custom node utility modules
    • Assembly Defintion
  • API
    • Nodes
    • Blackboard
    • Eventboard
    • FlowReactorComponent
    • FRVariables
      • FREnum
      • FRAttributes
    • INodeControllable
Powered by GitBook
On this page
  • Example 1
  • Example 2
  1. In-depth

Long running nodes

With FlowReactor version 2.0 it is possible to create nodes which run in a loop with async code.

Coroutine nodes have been deprecated since version 2

Example 1

This will run the node as long as its graph owner stays active. Use a sub-graph to activate / deactive such nodes.

public override async void OnExecute(FlowReactorComponent _flowReactor)
{	
	// Run code in a loop
	while(graphOwner.isActive)
	{
		Follow();
		await Task.Yield();
	}
}

Example 2

It is also possible to execute the next connected node while still running itself.

First we call ExecuteNext() to execute the connected node, then we run our loop. If the node gets deactivated, we call StopExecution to make sure the node highlight gets deactivated.

public override async void OnExecute(FlowReactorComponent _flowReactor)
{	
	// Execute output
	ExecuteNext(0, _flowReactor, true);
	// Run code in loop
	while(graphOwner.isActive)
	{
		Follow();
		await Task.Yield();
	}
	// Deactivate node highlight, should this node get deactivated
	StopExecution();
}
PreviousNode AttributesNextNode Modules

Last updated 2 years ago