unityzgy/Assets/Scripts/UIScripts/ThisProjectPublic/PromptWindows.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

75 lines
1.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using XFramework;
//一个通用的提示窗口 会遮挡其他界面 需关闭后才能操作其他界面
//初始化可注入显示内容和确定按钮的事件
//点击本界面关闭按钮时 隐藏本窗口 不做任何逻辑
//点击确认按钮时 会执行外界传入的确定事件
public class PromptWindows : BasePanel
{
const string windowName = "Panel_promptWindow";
Text text_msg;
UnityAction buttonSure;
public PromptWindows() : base(new UIType(windowName))
{
}
protected override void InitEvent()
{
text_msg = ActivePanel.GetComponentInChildren<Text>();
ActivePanel.FindChildTrans("Button_sure").GetComponentInChildren<Button>().onClick.AddListener(SureButtonOn);
ActivePanel.FindChildTrans("Button_Close").GetComponentInChildren<Button>().onClick.AddListener(CloseButtonOn);
}
public override void Change(object newData)
{
PromptWindowInitData initData = (PromptWindowInitData)newData;
ShowPromptWindow(initData.showMsg);
buttonSure = initData.buttonSure;//注册确定事件
}
void ShowPromptWindow(string value)
{
text_msg.text = value;
}
private void CloseButtonOn()
{
ClosePanel();
}
//确定事件
public void SureButtonOn()
{
ClosePanel();
buttonSure?.Invoke();
}
//关闭本界面
private void ClosePanel()
{
Pop();
}
}
//
public class PromptWindowInitData
{
public string showMsg;
public UnityAction buttonSure;//确认操作按钮
public PromptWindowInitData(string msg, UnityAction action)
{
showMsg = msg;
buttonSure = action;
}
}