Interface IOptionBuilder<TData>
Namespace: Unity.GraphToolkit.Editor
Assembly: Unity.GraphToolkit.Editor.dll
Syntax
public interface IOptionBuilder<in TData>
Type Parameters
Name | Description |
---|---|
TData |
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<in TData> Delayed()
Returns
Type | Description |
---|---|
IOptionBuilder<TData> |
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<in TData> ShowInInspectorOnly()
Returns
Type | Description |
---|---|
IOptionBuilder<TData> |
WithDefaultValue(TData)
Configures the default value for the option being built.
Declaration
IOptionBuilder<in TData> WithDefaultValue(TData defaultValue)
Parameters
Type | Name | Description |
---|---|---|
TData | defaultValue | The default value to assign to the option. |
Returns
Type | Description |
---|---|
IOptionBuilder<TData> |
WithDisplayName(string)
Configures the display name of the option being built.
Declaration
IOptionBuilder<in TData> WithDisplayName(string displayName)
Parameters
Type | Name | Description |
---|---|---|
string | displayName | The display name to assign to the option. |
Returns
Type | Description |
---|---|
IOptionBuilder<TData> |
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<in TData> WithTooltip(string tooltip)
Parameters
Type | Name | Description |
---|---|---|
string | tooltip | The tooltip text to assign to the option. |
Returns
Type | Description |
---|---|
IOptionBuilder<TData> |