Interface Node.IOptionDefinitionContext
Interface that provides methods to declare node options inside a node.
Namespace: Unity.GraphToolkit.Editor
Assembly: Unity.GraphToolkit.Editor.dll
Syntax
public interface Node.IOptionDefinitionContext
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
AddOption(string, Type)
Adds a new node option.
Declaration
IOptionBuilder AddOption(string name, Type dataType)
Parameters
Type | Name | Description |
---|---|---|
string | name | The unique identifier of the option. |
Type | dataType | The data type of the option. |
Returns
Type | Description |
---|---|
IOptionBuilder | An IOptionBuilder to further configure the option. |
Remarks
name
is used to identify the option. It must be unique among ports and options on the node. This name is used as the ID when calling GetNodeOptionByName(string).
If WithDisplayName(string) is not used, this name is also used as the option's display label.
Examples
protected override void OnDefineOptions(IOptionDefinitionContext context)
{
context.AddOption("MyOption", typeof(int)))
.WithDefaultValue(2)
.Delayed()
}
AddOption<TData>(string)
Adds a new node option.
Declaration
IOptionBuilder<TData> AddOption<TData>(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The unique identifier of the option. |
Returns
Type | Description |
---|---|
IOptionBuilder<TData> | An IOptionBuilder to further configure the option. |
Type Parameters
Name | Description |
---|---|
TData | The data type of the option. |
Remarks
name
is used to identify the option. It must be unique among ports and options on the node. This name is used as the ID when calling GetNodeOptionByName(string).
If WithDisplayName(string) is not used, this name is also used as the option's display label.
Examples
protected override void OnDefineOptions(IOptionDefinitionContext context)
{
context.AddOption<int>("MyOption")
.WithDefaultValue(2)
.Delayed()
}