UnityEngine.GUILayout.HorizontalSlider C# (CSharp) Method

HorizontalSlider() public static method

public static HorizontalSlider ( float value, float leftValue, float rightValue ) : float
value float
leftValue float
rightValue float
return float
        public static float HorizontalSlider (float value, float leftValue, float rightValue, params GUILayoutOption[] options) { return 0; }
        public static float HorizontalSlider (float value, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb, params GUILayoutOption[] options) { return 0; }

Same methods

GUILayout::HorizontalSlider ( float value, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb ) : float

Usage Example

コード例 #1
0
ファイル: UI+Controls.cs プロジェクト: ThyWoof/ToyBox
        public static bool LogSlider(String title, ref float value, float min, float max, float defaultValue = 1.0f, int decimals = 0, String units = "", params GUILayoutOption[] options)
        {
            if (min < 0)
            {
                throw new Exception("LogSlider - min value: {min} must be >= 0");
            }
            UI.BeginHorizontal(options);
            UI.Label(title.cyan(), UI.Width(300));
            UI.Space(25);
            value = Math.Max(min, Math.Min(max, value));    // clamp it
            var offset      = 1;
            var places      = (int)Math.Max(0, Math.Min(15, 2.01 - Math.Log10(value + offset)));
            var logMin      = 100f * (float)Math.Log10(min + offset);
            var logMax      = 100f * (float)Math.Log10(max + offset);
            var logValue    = 100f * (float)Math.Log10(value + offset);
            var logNewValue = (float)(GL.HorizontalSlider(logValue, logMin, logMax, UI.Width(200)));
            var newValue    = (float)Math.Round(Math.Pow(10, logNewValue / 100f) - offset, places);

            UI.Space(25);
            UI.FloatTextField(ref newValue, null, UI.Width(75));
            if (units.Length > 0)
            {
                UI.Label($"{units}".orange().bold(), UI.Width(25 + GUI.skin.label.CalcSize(new GUIContent(units)).x));
            }
            UI.Space(25);
            UI.ActionButton("Reset", () => { newValue = defaultValue; }, UI.AutoWidth());
            UI.EndHorizontal();
            bool changed = value != newValue;

            value = newValue;
            return(changed);
        }
All Usage Examples Of UnityEngine.GUILayout::HorizontalSlider