StateBehaviour

To customize StateBehaviour, you need to create a script file for StateBehaviour and describe what you want to do.

Create StateBehaviour script file

  • Right-click on the location you want to create from the Project window.
  • From the right-click menu, and select “Create> Arbor > State Behaviour C# Script”.
  • Determined to enter the file name

Function to be called

By assigning the created StateBehaviour to the state in ArborEditor, each function of the script will be called.

  • OnStateAwake
    It is called when it first enters the state.
  • OnStateBegin
    It is called when transitioning to state.
  • OnStateUpdate
    It will be called every frame at the timing of Update() of MonoBehaviour.
  • OnStateLateUpdate
    It will be called every frame at the timing of LateUpdate() of MonoBehaviour.
  • OnStateEnd
    It is called when leaving the state.
  • MonoBehaviour message functions
    For details, please see the MonoBehaviour Messages of Unity ScriptReference.

Important point

  • For enabled of MonoBehaviour are used internally already for execution control, please use the behaviourEnabled to be a substitute.

Execution Order

  • OnStateAwake / OnStateBegin / OnStateUpdate / OnStateLateUpdate / OnStateEnd is called in order from the top attached to the state node in Arbor Editor.
  • MonoBehaviour messages are invoked according to the order of execution by Unity.
    For details, refer to Execution Order of Event Functions in Unity Manual.

Variables and Arbor Editor

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

1
2
3
4
5
6
7
using UnityEngine;
using System.Collections;
using Arbor;

public class TestBehaviour : StateBehaviour {
	public string myName;
}

State connection

Add field

By declaring StateLink with the public or SerializeField attribute added to the created script, connection slots will be displayed in Arbor Editor.

1
2
3
4
5
6
7
8
using UnityEngine;
using System.Collections;
using Arbor;

public class TestBehaviour : StateBehaviour {
	public StateLink nextState;
	// Hereinafter abbreviated
}

Transition to connection destination

It is referred to as the Transition in the transition you want to timing.

1
	Transition( nextState );

Data flow

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

For details, see “Scripting: Data flow”.

Scripting : Data flow