Class Node
A base class for behaviour nodes used in the Behavior graph.
Inherited Members
Namespace: Unity.Behavior
Assembly: Unity.Behavior.dll
Syntax
[Serializable]
public abstract class Node
Properties
CurrentStatus
The current status of the graph node.
Declaration
[CreateProperty]
public Node.Status CurrentStatus { get; protected set; }
Property Value
| Type | Description |
|---|---|
| Node.Status |
GameObject
The game object that contains the BehaviorGraphAgent that is running the behavior graph.
Declaration
public GameObject GameObject { get; }
Property Value
| Type | Description |
|---|---|
| GameObject |
Methods
AwakeNode(Node)
Awakens a node if it is currently waiting on a child node or branch.
Declaration
protected void AwakeNode(Node node)
Parameters
| Type | Name | Description |
|---|---|---|
| Node | node | The node to awaken. |
AwakeParents()
AwakeParents is called after the running node has returned a status of Success or Fail.
Declaration
protected virtual void AwakeParents()
EndNode(Node)
Ends the execution of the specified node.
Declaration
protected void EndNode(Node node)
Parameters
| Type | Name | Description |
|---|---|---|
| Node | node | The node for which execution should end |
LogFailure(string, bool)
Log failure to the editor with additional contextual data.
Declaration
public void LogFailure(string reason, bool isError = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | reason | Reason for the failure. |
| bool | isError | If true, report the message using LogError instead of LogWarning. |
OnDeserialize()
Message raised after a graph is deserialized. Can be use to restart waiting nodes or reconstruct complex data that cannot be serialized.
Declaration
protected virtual void OnDeserialize()
OnEnd()
OnEnd is called when the node has stopped running.
Declaration
protected virtual void OnEnd()
OnSerialize()
Message raised before a graph is serialized. Can be use to prepare data for deserialization.
Declaration
protected virtual void OnSerialize()
OnSetup()
OnSetup is called once when the behavior graph instance is initialized, before any OnStart or OnUpdate calls. Use this method to cache data or perform one-time node setup. The order in which nodes are set up is not guaranteed.
Declaration
protected virtual void OnSetup()
OnStart()
OnStart is called when the node starts running.
Declaration
protected virtual Node.Status OnStart()
Returns
| Type | Description |
|---|---|
| Node.Status | The status of the node. |
OnTeardown()
OnTeardown is called once when the behavior graph instance is released. Use this method to unregister callbacks, release temporary resources, and clean up one-time setup done in OnSetup().
Declaration
protected virtual void OnTeardown()
OnUpdate()
OnUpdate is called each frame while the node is running.
Declaration
protected virtual Node.Status OnUpdate()
Returns
| Type | Description |
|---|---|
| Node.Status | The status of the node. |
ResetStatus()
Resets the current status of the node.
Declaration
protected virtual void ResetStatus()
StartNode(Node)
Starts the specified node. If the node completes, the parent node is notified.
Declaration
protected Node.Status StartNode(Node node)
Parameters
| Type | Name | Description |
|---|---|---|
| Node | node | The node to start |
Returns
| Type | Description |
|---|---|
| Node.Status | Returns the status of the node started. |