docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GraphAttribute

    Attribute used to declare a graph type by associating it with a file extension and optional configuration options.

    Inheritance
    object
    Attribute
    GraphAttribute
    Implements
    _Attribute
    Inherited Members
    Attribute.Equals(object)
    Attribute.GetCustomAttribute(Assembly, Type)
    Attribute.GetCustomAttribute(Assembly, Type, bool)
    Attribute.GetCustomAttribute(MemberInfo, Type)
    Attribute.GetCustomAttribute(MemberInfo, Type, bool)
    Attribute.GetCustomAttribute(Module, Type)
    Attribute.GetCustomAttribute(Module, Type, bool)
    Attribute.GetCustomAttribute(ParameterInfo, Type)
    Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(Assembly)
    Attribute.GetCustomAttributes(Assembly, bool)
    Attribute.GetCustomAttributes(Assembly, Type)
    Attribute.GetCustomAttributes(Assembly, Type, bool)
    Attribute.GetCustomAttributes(MemberInfo)
    Attribute.GetCustomAttributes(MemberInfo, bool)
    Attribute.GetCustomAttributes(MemberInfo, Type)
    Attribute.GetCustomAttributes(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(Module)
    Attribute.GetCustomAttributes(Module, bool)
    Attribute.GetCustomAttributes(Module, Type)
    Attribute.GetCustomAttributes(Module, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo)
    Attribute.GetCustomAttributes(ParameterInfo, bool)
    Attribute.GetCustomAttributes(ParameterInfo, Type)
    Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
    Attribute.GetHashCode()
    Attribute.IsDefaultAttribute()
    Attribute.IsDefined(Assembly, Type)
    Attribute.IsDefined(Assembly, Type, bool)
    Attribute.IsDefined(MemberInfo, Type)
    Attribute.IsDefined(MemberInfo, Type, bool)
    Attribute.IsDefined(Module, Type)
    Attribute.IsDefined(Module, Type, bool)
    Attribute.IsDefined(ParameterInfo, Type)
    Attribute.IsDefined(ParameterInfo, Type, bool)
    Attribute.Match(object)
    Attribute.TypeId
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    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.

    Implements

    _Attribute
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)