Class DropdownFieldExtensions
Namespace: Aspid.FastTools.UIElements
Assembly: Aspid.FastTools.dll
Provides extension methods for DropdownField.
public static class DropdownFieldExtensions
Inheritance
object ← DropdownFieldExtensions
Remarks
Counterparts of PopupFieldExtensions that need no type arguments.
PopupFieldExtensions.SetChoices<T1, T2> needs none either, so DropdownFieldExtensions.SetChoices<T>
only adds support for sources other than a List<T>.
Methods
SetChoices<T>(T, IEnumerable<string>)
Sets choices to a copy of value.
public static T SetChoices<T>(this T element, IEnumerable<string> value) where T : DropdownField
Parameters
element T
The element to modify.
value IEnumerable<string>
The choices to copy.
Returns
T
The element, for chaining.
Type Parameters
T
The field type.
Remarks
Use it for an array or a query. A List<T> argument calls
PopupFieldExtensions.SetChoices<T1, T2>, which keeps the list itself.
SetFormatListItemCallback<T>(T, Func<string, string>)
Sets formatListItemCallback, replacing any existing callback.
public static T SetFormatListItemCallback<T>(this T element, Func<string, string> value) where T : DropdownField
Parameters
element T
The element to modify.
The callback that formats a choice shown in the popup list.
Returns
T
The element, for chaining.
Type Parameters
T
The field type.
SetFormatSelectedValueCallback<T>(T, Func<string, string>)
Sets formatSelectedValueCallback, replacing any existing callback.
public static T SetFormatSelectedValueCallback<T>(this T element, Func<string, string> value) where T : DropdownField
Parameters
element T
The element to modify.
The callback that formats the selected value shown in the field.
Returns
T
The element, for chaining.
Type Parameters
T
The field type.
Remarks
Unity calls value at once with the current value, which is null for a
DropdownField before a choice is selected.
SetIndex<T>(T, int)
Sets index.
public static T SetIndex<T>(this T element, int value) where T : DropdownField
Parameters
element T
The element to modify.
value int
The index of the selected choice to set.
Returns
T
The element, for chaining.
Type Parameters
T
The field type.
Remarks
Unity resolves the index against the current choices: call
PopupFieldExtensions.SetChoices<T1, T2> or
DropdownFieldExtensions.SetChoices<T> first.