文档

Unity Engine


User Manual

Script Reference

Unity Engine


Implement block nodes for your graph tool

Create block nodes to enhance the functionality of your graph tool in Unity.
阅读时间1 分钟最后更新于 25 天前

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.
注意
Block node ports are always horizontal and, as such, the
AsVertical
method has no effect.
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. Implement a graph tool
  2. Implement a context node.

Implement a block node

To implement a block node, define a class to associate the block node with a context 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 { } #endregion MyBlockNode [Serializable] public class MyOtherContextNode : ContextNode { } #region MyBlockNodeWithMultipleContexts [UseWithContext(typeof(MyContextNode), typeof(MyOtherContextNode))] [Serializable] public class MyBlockNodeWithMultipleContexts : BlockNode { } #endregion MyBlockNodeWithMultipleContexts }}
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 { } #endregion MyBlockNodeWithMultipleContexts }}
Review Implement node options to learn how to customize your node with node options, ports, and orientation settings.

Additional resources