Data flow

Output slot

Data can be output by declaring an output slot such as OutpotSlotInt.

Example script

Create a TestOutputSlotBehaviour script file and write the following code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
using UnityEngine;
using Arbor;

[AddComponentMenu("")]
public class TestOutputSlotBehaviour : StateBehaviour
{
	public OutputSlotInt outputSlot;

	public override void OnStateBegin()
	{
		outputSlot.SetValue(Random.Range(100, 200));
	}
}

When this script is added to the state of ArborFSM, it becomes as follows.

Output slot class

Input slot

Data can be output by declaring an input slot such as InputSlotInt.

Example script

Create a TestInputSlotBehaviour script file and write the following code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
using UnityEngine;
using Arbor;

[AddComponentMenu("")]
public class TestInputSlotBehaviour : StateBehaviour
{
	public InputSlotInt inputSlot;

	public override void OnStateBegin()
	{
		int intValue = 0;
		if (inputSlot.GetValue(ref intValue))
		{
			Debug.Log("inputSlot : " + intValue);
		}
		else
		{
			Debug.LogWarning("inputSlot : not connected.");
		}
	}
}    

When this script is added to the state of ArborFSM, it becomes as follows.

Input slot class

FlexibleField

FlexibleField is useful for not only input slots but also constant values and parameters.

Example script

Create a TestFlexibleFieldBehaviour script file and write the following code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
using UnityEngine;
using Arbor;

[AddComponentMenu("")]
public class TestFlexibleFieldBehaviour : StateBehaviour
{
	public FlexibleInt flexibleInt;

	public override void OnStateBegin()
	{
		Debug.Log("flexibleInt : " + flexibleInt.value);
	}
}    

When this script is added to the state of ArborFSM, it becomes as follows.

FlexibleField related class

Type constraints of slots

For InputSlotAny and InputSlotComponent, you can specify type constraints with attributes.

Example script

Create TestConstraintSlotBehaviour script file and write the following code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
using UnityEngine;
using Arbor;

[AddComponentMenu("")]
public class TestConstraintSlotBehaviour : StateBehaviour
{
	[ClassExtends(typeof(AudioSource))]
	public InputSlotComponent audioSource = new InputSlotComponent();

	[ClassExtends(typeof(AudioClip))]
	public InputSlotUnityObject audioClip = new InputSlotUnityObject();

	[ClassExtends(typeof(AudioSourceCurveType))]
	public InputSlotAny audioSourceCurveType = new InputSlotAny();

	public FlexibleAnimationCurve curve = new FlexibleAnimationCurve(AnimationCurve.Linear(0, 0, 1, 1));

	public override void OnStateBegin()
	{
		AudioSource source_ = audioSource.GetValue<AudioSource>();
		AudioClip clip_ = audioClip.GetValue<AudioClip>();
		AudioSourceCurveType curveType_ = AudioSourceCurveType.CustomRolloff;
		audioSourceCurveType.GetValue<AudioSourceCurveType>(ref curveType_);

		AnimationCurve curve_ = curve.value;

		if (source_ == null || clip_ == null)
		{
			return;
		}

		source_.clip = clip_;
		source_.SetCustomCurve(curveType_, curve_);
	}
}    

Available Attributes

Class Attribute
OutputSlotAny SlotTypeAttribute
InputSlotAny Class derived from ClassTypeConstraintAttribute
SlotTypeAttribute
InputSlotComponent Class derived from ClassTypeConstraintAttribute
SlotTypeAttribute
It is also constrained to the Component class.
InputSlotUnityObject Class derived from ClassTypeConstraintAttribute
SlotTypeAttribute
It is also constrained to the UnityEngine.Object class.
FlexibleComponent Class derived from ClassTypeConstraintAttribute
SlotTypeAttribute
It is also constrained to the Component class.

DataLink attribute

By using DataLink attribute, input from constant or data flow can be accepted even if there is no corresponding type InputSlot or FlexibleField.

ScriptReference : DataLink

Example script

Create ExampleDataLinkBehaviour script file and write the following code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 
using UnityEngine;
using Arbor;

[AddComponentMenu("")]
public class ExampleDataLinkBehaviour : StateBehaviour
{
	[System.Serializable]
	public class ExampleData
	{
		public string name = "Test";
		public float power = 100f;
	}

	[DataLink]
	public ExampleData exampleData;
}

Notes

  • It can only be used in the fields of classes that inherit NodeBehaviour (such as StateBehaviour and ActionBehaviour).
  • It can not be used for arrays or lists.

Customize

Create data slot

You can also create a data slot of your own class.

For details, refer to “Scripting : Data Slot”.

Scripting : Data Slot

Variable

If you also create a parameter, you can create it easily using Variable Generator.

For details, see “Scripting : Variable”.

Scripting : Variable

Calculator node

You can also create scripts to use for calculator nodes.

For details, see “Scripting : Calculator”.

Scripting : Calculator