Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

State.IOptionDefinitionContext.AddOption

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public IStateOptionBuilder AddOption(string name, Type dataType);

Parameters

Parameter Description
name The unique identifier of the option.
dataType The data type of the option.

Returns

IStateOptionBuilder An IStateOptionBuilder to further configure the option.

Description

Adds a new state option.

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.

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

Declaration

public IStateOptionBuilder<TData> AddOption(string name);

Parameters

Parameter Description
name The unique identifier of the option.

Returns

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

Description

Adds a new state option.

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<T0>.WithDisplayName is not used, this name is also used as the option's display label.

 protected override void OnDefineOptions(IOptionDefinitionContext context)
 {
     context.AddOption<int>("MyOption")
         .WithDefaultValue(2)
         .Delayed();
 }