Calculator
To customize a calculator node, you need to create a script file for the calculator node and describe the process you want to do.
Create a Calculator script file
- Right-click on the location you want to create from the Project window.
- From the right-click menu, and select “Create> Arbor > Calculator C# Script”.
- Determined to enter the file name
Function to be called
By assigning the created Calculator to a calculator node in ArborEditor, each function of the script will be called.
- OnCalculate
It is called when calculation is required.
Describe the operation process here and output the data with OutputSlot.SetValue. - OnCheckDirty
It is called to determine if recalculation is necessary. Please override as necessary.
Please return whether necessary data for calculation has been changed and recalculation is necessary.
It is not necessary to be conscious of recalculation depending on the connection state of the input slot because it is judged internally by Arbor.
(It should be true to handle external object values, such as Transform.position) - MonoBehaviour message functions
For details, please see the MonoBehaviour Messages of Unity ScriptReference.
Flow of calculation
- Call InputSlot.GetValue () as necessary.
- OnCheckDirty is called to determine if recalculation is necessary.
(If the value was changed beforehand by OutputSlot.SetValue, recalculation will be performed regardless of the result of OnCheckDirty) - On recalculation is required OnCalculate is called.
- Call InputSlot.GetValue () as necessary in OnCaluculate.
- Below, we will trace InputSlot to get the value until recalculation is no longer needed.
Variables and Arbor Editor
Basically, as with StateBehaviours Variables and Arbor Editor, declaring variables makes it displayable in Arbor Editor and editable.
Data flow
It is important to input and output values by data flow in order to utilize compute nodes.
For details, see “Scripting: Data flow”.