You can create an ActionBehaviour script and add the original action by describing what you want to do.

Create an ActionBehaviour script file

  • Right click at the place you want to create from the Project window.
  • From the right-click menu, select “Create > Arbor > Behavior tree > ActionBehaviour C# Script”.
  • Enter the file name and confirm

Function to be called

If you add the ActionBehavior you created to the Behavior Tree graph, each function of the script will be called.

  • OnAwake
    It is called the first time the action node becomes active.
  • OnStart
    Called when the action node becomes active.
  • OnExecute
    It is called when the action node is executed.
    For the execution timing, see UpdateSettings and ExecutionSettings in BehaviourTree.
    Arbor Reference : BehaviourTree
  • OnAbort
    Called when the node is interrupted by the Decorator.
  • OnEnd
    Called when the action node exits.
  • OnUpdate
    Called at the timing of BehaviourTree's Update().
    Whether it is called every frame or not depends on BehaviourTree's Update Settings.
  • OnLateUpdate
    It is called at the timing of BehaviourTree's LateUpdate().
    Whether it is called every frame or not depends on BehaviourTree's Update Settings.
  • OnFixedUpdate
    It is called at the timing of FixedUpdate() in BehaviourTree.
  • OnGraphPause
    Called when a graph is paused while playing.
  • OnGraphResume
    Called when a graph is resumed from pause.
  • OnGraphStop
    Called when a graph stops playing.
  • MonoBehaviour message functions
    For details, please see the MonoBehaviour Messages of Unity ScriptReference.

Call order

(The above image is for reference only and is not accurate.)

  • You can also use the callback method of MonoBehaviour other than OnEnable and OnDisable, but please be aware that Start () will be called after OnExecute().

Declaring fields

You can edit it in Arbor Editor by declaring a field with public or SerializedField attribute added to the created script.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Arbor;
using Arbor.BehaviourTree;

public class TestActionBehaviour : ActionBehaviour
	public string myName;
	// The rest is omitted.

It is similar to editing a field from the Inspector.
For details, refer to the following Unity manual.

Finish Execute

It can be completed by calling FinishExecute(bool result). Note that FinishExecute can only be called within the OnExecute method.

	if (Input.GetKey(KeyCode.Space) )

Data flow

It is possible to input / output values by data flow.

For details, see Scripting : Data flow.


It supports asynchronous wait by async/await.

See async/await for more information.

Additional explanation

  • The file name and class name must be the same.
  • If the file is placed under a special folder such as Editor folder, it will not be recognized.
  • The AddComponentMenu("") that is automatically given is to prevent it from being displayed in Inspector's Add Component.
  • We do not support the behavior of adding directly to GameObjects without going through the graph.
  • The C# script needs to be compiled to reflect the changes.
    If you have turned off Auto Refresh in Preferences, for example, you will need to manually do “Assets > Refresh” from the menu.
  • MonoBehaviour's enabled is used internally for execution control, so please use the alternative behaviourEnabled.