Customize Decorator


This is the documentation for Arbor 3.2.4 and earlier.

See Arbor Documentation for the latest documentation.

You can add original condition judgment and loop processing by creating a Decorator script and describing what you want to do.

Creating a Decorator 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> Decorator C# Script”.
  • Enter the file name and confirm

Function to be called

If you add the created Decotarot to the composite node or action node, each function of the script will be called.

  • OnAwake
    It is called the first time the node becomes active.
  • OnStart
    It is called when the node becomes active.
  • OnAbort
    Called when the node is interrupted by the Decorator.
  • OnEnd
    Called when the node exits.
  • HasConditionCheck
    It is called to determine whether ConditionCheck is done or not.
    If ConditionCheck is not done, please override and return false.
    Default is true.
  • OnConditionCheck
    It is called when condition judgment is performed.
    Please return true if it matches the condition, false if it does not match.
    Whether to abort or not is ultimately determined by AbortFlags.
  • OnRepeatCheck
    It is called to determine whether to repeat if the node terminates normally.
    To repeat please return true.
    Default is false.
  • OnFinishExecute
    It is called to change the execution result.
    By default, it returns the received result as it is.

Call order

  • If more than one Decorator is added to the node, it is called in order from the top.
  • You can also use the callback method of MonoBehaviour other than OnEnable and OnDisable, but please be aware that Start () will be called after OnConditionCheck () etc.

Declaring variables

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;

[AddComponentMenu("")]
public class TestDecorator : Decorator {
	public string myName;
	// The rest is omitted.
}

You can also use CalculatorSlot and Flexible classes as well as StateBehaviour.