Class GraphAttribute
Attribute used to declare a graph type by associating it with a file extension and optional configuration options.
Implements
Inherited Members
Namespace: Unity.GraphToolkit.Editor
Assembly: Unity.GraphToolkit.Editor.dll
Syntax
[AttributeUsage(AttributeTargets.Class)]
public sealed class GraphAttribute : Attribute, _Attribute
Remarks
Use this attribute to associate a custom Graph class with a unique file extension and GraphOptions.
The extension
parameter defines the file extension for the graph assets. This extension must be unique across the project
because Unity uses it to select the correct importer. You can also configure additional options using GraphOptions.
This attribute is required for any class that inherits from Graph and serves as the entry point for enabling
editor support for the graph tool.
Examples
This example keeps the default behavior and adds support for subgraphs by enabling SupportsSubgraphs.
[Graph(".mygraph", GraphOptions.SupportsSubgraphs)]
public class MyGraph : Graph { }
Constructors
GraphAttribute(string, GraphOptions)
Initializes a new instance of the GraphAttribute class with a file extension and optional graph options.
Declaration
public GraphAttribute(string extension, GraphOptions options = GraphOptions.Default)
Parameters
Type | Name | Description |
---|---|---|
string | extension | The file extension to associate with assets of the graph type. This value must be unique because Unity uses it to select the correct importer. |
GraphOptions | options | The configuration options for the graph. Defaults to Default if not specified. |
Remarks
Use this constructor to define the asset extension and configure the graph. This allows for proper asset recognition and import handling by Unity. The values in GraphOptions support bitwise combination. Combine multiple flags to configure the graph with custom behavior.
Examples
This example keeps the default behavior and adds support for subgraphs by enabling SupportsSubgraphs.
[Graph(".mygraph", GraphOptions.SupportsSubgraphs)]
public class MyGraph : Graph { }
Properties
extension
Gets the file extension associated with the Graph.
Declaration
public string extension { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
The extension must be unique across all asset types. Unity uses this extension to determine which importer to use for the asset. For example, if the extension is ".mygraph", Unity uses the importer linked to this Graph type for all files with that extension.
options
Gets the graph configuration options.
Declaration
public GraphOptions options { get; }
Property Value
Type | Description |
---|---|
GraphOptions |
Remarks
These options define specific behaviors of the graph, such as SupportsSubgraphs or DisableAutoInclusionOfNodesFromGraphAssembly.