unityzgy/Assets/Scripts/UIScripts/Teacher/Mono/AppraiseSliderCtrl.cs
ayuan9957 31a3fb4f30 fix: 翻译完善 + 预制体verticalOverflow + 连续训练相机修复
- PromptTextCtrl: 新增SetPromptLocalized支持3秒内实时翻译
- StudentSub2EditorPanel: 3处SetPrompt改SetPromptLocalized
- AppraiseSliderCtrl: 评价指标名称用Get()翻译
- WaitResultPanel: 评价等级用Get()翻译避免先闪中文
- EditorAppraiser: 厂区距离提示中厂区名称先Get()翻译
- GameObjectManager: 距离提示用Get()翻译
- StudentSub2EditorPanel: Text_terrainName同步地形名+实时翻译
- SubStart: 车辆列表为空时回退CameraPos定位相机
- 所有UI预制体verticalOverflow改为Overflow(322处)
- LocalizationManager/LoginPanel/HistoryPanel/VRTooltip: 移除强制Overflow
- 分组错误提示用Get()翻译+新增4条翻译
- 山地作为林地别名在代码回退字典中
2026-08-04 10:33:05 +08:00

54 lines
1.8 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;
LocalizationManager.SetFormatted(pointName, "{0}", LocalizationManager.Get(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;//保持在中间
}
}