Class SubgraphAttribute
Attribute used to define a link between a subgraph type and a main graph type.
Implements
Inherited Members
Namespace: Unity.GraphToolkit.Editor
Assembly: Unity.GraphToolkit.Editor.dll
Syntax
public sealed class SubgraphAttribute : Attribute, _Attribute
Remarks
Apply this attribute to a custom Graph class to declare it as a valid subgraph type for a specific parent (main) graph type.
This attribute is required when you want to designate a specific graph type to function as a subgraph in tools that support subgraphs.
Use it on custom graph classes that are designed to act as subgraphs.
This is useful when you want to provide specialized subgraph behaviors, customize the user experience, or restrict subgraph usage
to certain graph types.
When a graph type declares that it supports subgraphs using SupportsSubgraphs
but no corresponding SubgraphAttribute is found, the main graph type itself is used as the subgraph type by default.
You can associate multiple subgraph types with the same main graph type. In this case, the editor's context menu includes multiple
"Create Subgraph class name
Subgraph from Selection" actions—one for each valid subgraph type.
Examples
// This declares a subgraph type used by MyMainGraph
[Subgraph(typeof(MyMainGraph))]
public class MySubgraph : Graph
Constructors
SubgraphAttribute(Type)
Initializes a new instance of the SubgraphAttribute class.
Declaration
public SubgraphAttribute(Type mainGraphType)
Parameters
Type | Name | Description |
---|---|---|
Type | mainGraphType | The type of the main Graph that this subgraph type is compatible with. This must be a type that inherits from Graph. |
Remarks
Use this constructor to associate a custom subgraph class with a parent graph type. This enables the graph tool to recognize the subgraph as a valid option for the specified main graph. The attribute must be applied to a Graph-derived class intended to function as a subgraph.
Examples
// This declares a subgraph type used by MyMainGraph
[Subgraph(typeof(MyMainGraph))]
public class MySubgraph : Graph
Properties
MainGraphType
The type of the main Graph that supports this subgraph type.
Declaration
public Type MainGraphType { get; }
Property Value
Type | Description |
---|---|
Type |