docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface INodeOptionDefinition

    Interface that provides methods to declare node options inside a node.

    Namespace: Unity.GraphToolkit.Editor
    Assembly: Unity.GraphToolkit.Common.Editor.dll
    Syntax
    public interface INodeOptionDefinition
    Remarks

    Use to add node options on nodes. Node options appear under the node header and in the inspector when a node is selected. They are appropriate for parameters that affect how a node behaves or changes its topology, such as modifying the number of ports.

    Methods

    AddNodeOption(string, Type, string, string, bool, int, Attribute[], object)

    Adds a node option to the node.

    Declaration
    void AddNodeOption(string optionName, Type dataType, string optionDisplayName = null, string tooltip = null, bool showInInspectorOnly = false, int order = 0, Attribute[] attributes = null, object defaultValue = null)
    Parameters
    Type Name Description
    string optionName

    The name of the node option, used for identification.

    Type dataType

    The data type of the node option.

    string optionDisplayName

    The name of the option shown in the UI, if specified.

    string tooltip

    The tooltip to display when hovering over the option in the UI.

    bool showInInspectorOnly

    If true, shows the option only in the Inspector. By default, the option is shown in the Inspector and on the node.

    int order

    The order index used to position this option relative to others. Lower values appear first.

    Attribute[] attributes

    An array of attributes to apply to the option field.

    object defaultValue

    The default value assigned to the option when the node is created.

    Remarks

    Call this method in Node.OnDefineOptions to declare node-level settings. Use Node.GetNodeOptionByName(string) or Node.GetNodeOption(int) to retrieve the option. The optionName is unique within the node's input ports and node options.

    Examples
    protected override void OnDefineOptions(INodeOptionDefinition context)
    {
        context.AddNodeOption(
            optionName: "Label",
            dataType: typeof(string),
            optionDisplayName: "My Label",
            tooltip: "A label.",
            defaultValue: "Default Value");
    }

    AddNodeOption<T>(string, string, string, bool, int, Attribute[], T)

    Adds a node option to the node.

    Declaration
    void AddNodeOption<T>(string optionName, string optionDisplayName = null, string tooltip = null, bool showInInspectorOnly = false, int order = 0, Attribute[] attributes = null, T defaultValue = default)
    Parameters
    Type Name Description
    string optionName

    The name of the node option, used for identification.

    string optionDisplayName

    The name of the option shown in the UI, if specified.

    string tooltip

    The tooltip to display when hovering over the option in the UI.

    bool showInInspectorOnly

    If true, shows the option only in the Inspector. By default, the option is shown in the Inspector and on the node.

    int order

    The order index used to position this option relative to others. Lower values appear first.

    Attribute[] attributes

    An array of attributes to apply to the option field.

    T defaultValue

    The default value assigned to the option when the node is created.

    Type Parameters
    Name Description
    T

    The data type of the node option.

    Remarks

    Call this method in Node.OnDefineOptions to declare node-level settings. Use Node.GetNodeOptionByName(string) or Node.GetNodeOption(int) to retrieve the option. The optionName is unique within the node's input ports and node options.

    Examples
    protected override void OnDefineOptions(INodeOptionDefinition context)
    {
        context.AddNodeOption<string>(
            optionName: "Label",
            optionDisplayName: "My Label",
            tooltip: "A label.",
            defaultValue: "Default Value");
    }
    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)