Delegate Slider<TValue, TScalar, TInputField>.ScaleHandler
Handler to scale the value of the slider thumbs and marks.
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public delegate TScalar Slider<TValue, TScalar, TInputField>.ScaleHandler(TScalar value)
Parameters
Type | Name | Description |
---|---|---|
TScalar | value | The value to scale. |
Returns
Type | Description |
---|---|
TScalar | The scaled value. |
Remarks
The scale is only applied to the formatted value displayed as text.
Examples
var scaledSlider = new SliderInt
{
scale = v => (int)Mathf.Pow(2, v),
formatFunction = v => {
var units = new string[] { "KB", "MB", "GB", "TB" };
var unitIndex = 0;
var scaledValue = v;
while (scaledValue >= 1024 && unitIndex < units.Length - 1)
{
scaledValue /= 1024;
unitIndex++;
}
return $"{scaledValue} {units[unitIndex]}";
}
};