Version: Unity 6.4 (6000.4)
Language : English
Implement context nodes for your graph tool
Implement node options

Implement block nodes for your graph tool

Create block nodes to define the functionality of the context nodes of your graph tool in Unity.

Block nodes are nodes that perform a single operation or behavior. Block nodes inherit all features available in their parent Node class.

This page covers how to implement block nodes only. For information on how to implement context nodes, refer to Implement context nodes for your graph tool. For information about node types, refer to About nodes.

Prerequisites

  1. Create a Graph class.
  2. Create a Graph asset.
  3. Implement a context node, as described in Implement a context node.

Implement and instantiate a block node

To implement a block node, define a class to associate the block node with a context node, and instantiate the node.

Define a class

To implement a block node:

  1. Define a class that inherits from the BlockNode base class.
  2. Add the UseWithContext attribute, and provide it with the type of the ContextNode to associate the block node with.

The resulting code looks like:


[UseWithContext(typeof(MyContextNode))]
[Serializable]
public class MyBlockNode : BlockNode
{
}


[UseWithContext(typeof(MyContextNode), typeof(MyOtherContextNode))]
[Serializable]
public class MyBlockNodeWithMultipleContexts : BlockNode
{
}

To associate a block node with several context nodes, list them separated with a comma in your UseWithContext attribute:


[UseWithContext(typeof(MyContextNode), typeof(MyOtherContextNode))]
[Serializable]
public class MyBlockNodeWithMultipleContexts : BlockNode
{
}

Review Implement node options to learn how to customize your node with node options, ports, and orientation settings.

Instantiate the node

To add a block node inside a context node:

  1. In the context node, select Add a Block. The Add a graph node window opens and displays all the blocks you can add to the context node.

  2. To add a block node to the context node, double-click the block node.

After you add it, you can disable, remove or connect a block node the same way as other nodes.

Additional resources

Implement context nodes for your graph tool
Implement node options
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961