Class PopupFieldExtensions
Namespace: Aspid.FastTools.UIElements
Assembly: Aspid.FastTools.dll
Provides extension methods for PopupField<T>.
public static class PopupFieldExtensions
Inheritance
Remarks
Only PopupFieldExtensions.SetChoices<T1, T2> infers the choice type. The other methods need explicit type
arguments; DropdownField has overloads without them in DropdownFieldExtensions.
Methods
SetChoices<TField, TChoice>(TField, List<TChoice>)
Sets choices.
public static TField SetChoices<TField, TChoice>(this TField element, List<TChoice> value) where TField : PopupField<TChoice>
Parameters
element TField
The element to modify.
value List<TChoice>
The list of choices to set.
Returns
TField
The element, for chaining.
Type Parameters
TField
The field type.
TChoice
The choice type held by the field.
SetFormatListItemCallback<TField, TChoice>(TField, Func<TChoice, string>)
Sets formatListItemCallback, replacing any existing callback.
public static TField SetFormatListItemCallback<TField, TChoice>(this TField element, Func<TChoice, string> value) where TField : PopupField<TChoice>
Parameters
element TField
The element to modify.
The callback that formats a choice shown in the popup list.
Returns
TField
The element, for chaining.
Type Parameters
TField
The field type.
TChoice
The choice type held by the field.
SetFormatSelectedValueCallback<TField, TChoice>(TField, Func<TChoice, string>)
Sets formatSelectedValueCallback, replacing any existing callback.
public static TField SetFormatSelectedValueCallback<TField, TChoice>(this TField element, Func<TChoice, string> value) where TField : PopupField<TChoice>
Parameters
element TField
The element to modify.
The callback that formats the selected value shown in the field.
Returns
TField
The element, for chaining.
Type Parameters
TField
The field type.
TChoice
The choice type held by the field.
Remarks
Unity calls value at once with the current value, which is null for a
reference type before a choice is selected.
SetIndex<TField, TChoice>(TField, int)
Sets index.
public static TField SetIndex<TField, TChoice>(this TField element, int value) where TField : PopupField<TChoice>
Parameters
element TField
The element to modify.
value int
The index of the selected choice to set.
Returns
TField
The element, for chaining.
Type Parameters
TField
The field type.
TChoice
The choice type held by the field.
Remarks
Unity resolves the index against the current choices: call PopupFieldExtensions.SetChoices<T1, T2> first.