public override void Initialize(SettingsControlModel controlConfig, SettingsControlController settingsControlController)
        {
            this.sliderControlConfig = (SliderControlModel)controlConfig;
            slider.maxValue          = this.sliderControlConfig.sliderMaxValue;
            slider.minValue          = this.sliderControlConfig.sliderMinValue;
            slider.wholeNumbers      = this.sliderControlConfig.sliderWholeNumbers;

            sliderController = (SliderSettingsControlController)settingsControlController;
            sliderController.OnIndicatorLabelChange += OverrideIndicatorLabel;

            base.Initialize(controlConfig, sliderController);
            OverrideIndicatorLabel(slider.value.ToString());
            sliderController.UpdateSetting(this.sliderControlConfig.storeValueAsNormalized ? RemapSliderValueTo01(slider.value) : slider.value);

            slider.onValueChanged.AddListener(sliderValue =>
            {
                OverrideIndicatorLabel(sliderValue.ToString());
                ApplySetting(this.sliderControlConfig.storeValueAsNormalized ? RemapSliderValueTo01(sliderValue) : sliderValue);
            });
        }
Beispiel #2
0
        public override void Initialize(SettingsControlModel controlConfig, SettingsControlController settingsControlController)
        {
            sliderController = (SliderSettingsControlController)settingsControlController;
            sliderController.OnIndicatorLabelChange += OverrideIndicatorLabel;

            this.sliderControlConfig = (SliderControlModel)controlConfig;
            slider.maxValue          = this.sliderControlConfig.sliderMaxValue;
            slider.minValue          = this.sliderControlConfig.sliderMinValue;
            slider.wholeNumbers      = false;

            base.Initialize(controlConfig, sliderController);
            OverrideIndicatorLabel(slider.value.ToString());
            sliderController.UpdateSetting(this.sliderControlConfig.storeValueAsNormalized ? RemapSliderValueTo01(slider.value) : slider.value);

            slider.onValueChanged.AddListener(sliderValue =>
            {
                // https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings
                // FX = floating point with X precision digits
                string stringFormat = sliderControlConfig.wholeNumbers ? "F0" : "F1";

                OverrideIndicatorLabel(sliderValue.ToString(stringFormat));
                ApplySetting(this.sliderControlConfig.storeValueAsNormalized ? RemapSliderValueTo01(sliderValue) : sliderValue);
            });
        }