public override void UpdateData(ScrollViewCell cell) { _sliderCell = (BaseSliderCell)cell; _sliderCell.OnValueChanged = OnValueChanged; var rangeAttr = variableInfo.fieldInfo.GetCustomAttribute <RangeAttribute>(false); var relativeAttr = variableInfo.fieldInfo.GetCustomAttribute <RelativeSliderAttribute>(false); bool isWholeNumbers = variableInfo.fieldInfo.FieldType != typeof(float) && variableInfo.fieldInfo.FieldType != typeof(double); float value = (float)Convert.ChangeType(variableInfo.fieldInfo.GetValue(command), typeof(float)); _sliderCell.UseRelativeSlider(relativeAttr != null); _sliderCell.SetConfig(rangeAttr.min, rangeAttr.max, isWholeNumbers); _sliderCell.SetValue(Mathf.Clamp(value, rangeAttr.min, rangeAttr.max)); }
void OnValueChanged(BaseSliderCell cell, float value) { variableInfo.fieldInfo.SetValue(command, Convert.ChangeType(value, variableInfo.fieldInfo.FieldType)); base.OnValueChanged(); }