Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AddOption

Adds a new state option.
Read time 1 minuteLast updated 13 days ago

Definition

AddOption(string, Type)

Adds a new state option.
IStateOptionBuilder AddOption(string name, Type dataType)

Parameters

name

The unique identifier of the option.

dataType

The data type of the option.

Returns

Type

Description

IStateOptionBuilderAn IStateOptionBuilder to further configure the option.

Remarks

name
is used to identify the option. It must be unique among the options on the state. This name is used as the ID when calling State.GetOptionByName. If IStateOptionBuilder.WithDisplayName 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<T>(string)

Adds a new state option.
IStateOptionBuilder<TData> AddOption<TData>(string name)

Parameters

name

The unique identifier of the option.

Returns

Type

Description

IStateOptionBuilder<T>An IStateOptionBuilder to further configure the option.

Remarks

name
is used to identify the option. It must be unique among the options on the state. This name is used as the ID when calling State.GetOptionByName. If IStateOptionBuilder<TData>.WithDisplayName 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();}