docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IOptionBuilder

    Interface used to build and configure node options in a fluent manner.

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

    Provided by the Node.IOptionDefinitionContext in a node's OnDefineOptions(IOptionDefinitionContext) method.

    Examples
    protected override void OnDefineOptions(IOptionDefinitionContext context)
    {
        context.AddOption("MyOption", typeof(int)))
            .WithDefaultValue(2)
            .Delayed();
    }

    Methods

    Build()

    Builds and returns the final INodeOption instance based on the current configuration of the builder.

    Declaration
    INodeOption Build()
    Returns
    Type Description
    INodeOption

    The constructed INodeOption.

    Remarks

    This method is optional. All options are automatically built when the node's OnDefineOptions(IOptionDefinitionContext) method completes.

    Calling this method releases the memory associated with this option back into the pool immediately. You can choose to call this method if there are lots of options being defined to reduce peak memory usage.

    Only call this after setting all desired configuration options using the builder methods.

    Examples
    protected override void OnDefineOptions(IOptionDefinitionContext context)
    {
        context.AddOption("MyOption", typeof(int)))
            .WithDefaultValue(2)
            .Delayed()
            .Build();
    }

    Delayed()

    Configures the input port to use the DelayedAttribute.

    Declaration
    IOptionBuilder Delayed()
    Returns
    Type Description
    IOptionBuilder
    Remarks

    Apply this setting when the option’s value should only update after the user finishes editing input in the UI. This is useful for optimizing performance or avoiding intermediate updates during data entry.

    ShowInInspectorOnly()

    Configures the option to be shown only in the inspector, not in the node header.

    Declaration
    IOptionBuilder ShowInInspectorOnly()
    Returns
    Type Description
    IOptionBuilder

    WithDefaultValue(object)

    Configures the default value for the option being built.

    Declaration
    IOptionBuilder WithDefaultValue(object defaultValue)
    Parameters
    Type Name Description
    object defaultValue

    The default value to assign to the option.

    Returns
    Type Description
    IOptionBuilder

    WithDisplayName(string)

    Configures the display name of the option being built.

    Declaration
    IOptionBuilder WithDisplayName(string displayName)
    Parameters
    Type Name Description
    string displayName

    The display name to assign to the option.

    Returns
    Type Description
    IOptionBuilder
    Remarks

    The display name doesn't affect functionality; it can improve usability and readability. If not set explicitly using this method, the name passed during creation (calling AddOption(string, Type)) is used as the default display name.

    WithTooltip(string)

    Configures the tooltip text for the option being built.

    Declaration
    IOptionBuilder WithTooltip(string tooltip)
    Parameters
    Type Name Description
    string tooltip

    The tooltip text to assign to the option.

    Returns
    Type Description
    IOptionBuilder
    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)