docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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]}";
       }
    };
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)