unityzgy/Assets/Scripts/UIScripts/Teacher/Mono/AppraiseSliderCtrl.cs
ayuan9957 bf12e02276 feat: 多语言本地化系统 - 支持中/英/法/俄实时切换
- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg)
- LoginPanel: InputField placeholder本地化、字体颜色保持
- HistoryPanel: 用时数据本地化、placeholder本地化
- RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建)
- AppraiseWindowBase: 评价等级本地化、操作消息重建
- EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized
- StudentOperateRecorder: 新增InjectOperateMsgLocalized方法
- LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选
- 字体切换时保留颜色和verticalOverflow
2026-07-16 10:05:59 +08:00

54 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
//评价指标滑块控制类
public class AppraiseSliderCtrl : MonoBehaviour
{
public Slider slider_weight;//权重滑块
public Text pointName;//显示评价指标类型
public Text showSliderValue;//显示滑块值
string currentName;
string valueUnit;
UnityAction<string, float> valueChangedEvent;
// Start is called before the first frame update
void Awake()
{
slider_weight.minValue = 0;
slider_weight.maxValue = 20;
slider_weight.wholeNumbers = true;
slider_weight.onValueChanged.AddListener(SliderValueChanged);
slider_weight.value = (slider_weight.minValue + slider_weight.maxValue) / 2;
}
/// <summary>
/// 注入初始化参数 返回当前权重值
/// </summary>
/// <param name="Name"></param>
/// <param name="valueChanged"></param>
/// <returns>当前权重值</returns>
public float InjectInitData(string Name, UnityAction<string, float> valueChanged)
{
this.valueChangedEvent = valueChanged;
currentName = Name;
pointName.text = currentName + "";
return slider_weight.value/10;
}
protected virtual void SliderValueChanged(float value)
{
float trueValue = value / 10f;//转换为0-2便于显示和后续计算
showSliderValue.text = trueValue.ToString("0.0");
valueChangedEvent?.Invoke(currentName, trueValue);
}
//隐藏时 初始化slider
private void OnDisable()
{
valueChangedEvent = null;
slider_weight.value = (slider_weight.minValue+slider_weight.maxValue)/2;//保持在中间
}
}