- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
181 lines
4.5 KiB
C#
181 lines
4.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using DevelopEngine;
|
|
|
|
|
|
public interface IEventInfo
|
|
{ }
|
|
|
|
public class EventInfo<T,K> : IEventInfo
|
|
{
|
|
public UnityAction<T,K> actions;
|
|
|
|
public EventInfo(UnityAction<T,K> action)
|
|
{
|
|
actions += action;
|
|
}
|
|
|
|
}
|
|
|
|
public class EventInfo<T> : IEventInfo
|
|
{
|
|
public UnityAction<T> actions;
|
|
|
|
public EventInfo(UnityAction<T> action)
|
|
{
|
|
actions += action;
|
|
}
|
|
|
|
}
|
|
|
|
public class EventInfo : IEventInfo
|
|
{
|
|
public UnityAction actions;
|
|
|
|
public EventInfo(UnityAction action)
|
|
{
|
|
actions += action;
|
|
}
|
|
}
|
|
|
|
|
|
///<summary>
|
|
///1.Dictionary
|
|
/// 多波委托 使用时注意事件生命周期 及时注销
|
|
///<summary>
|
|
public class EventCenter : MonoSingleton<EventCenter>
|
|
{
|
|
private Dictionary<string, IEventInfo> eventDic =
|
|
new Dictionary<string, IEventInfo>();
|
|
|
|
/// <summary>
|
|
/// 添加事件监听
|
|
/// </summary>
|
|
/// <param name="name">事件名字</param>
|
|
/// <param name="action"> 事件 的委托函数</param>
|
|
public void AddEventListener<T,K>(string name, UnityAction<T,K> action)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
(eventDic[name] as EventInfo<T,K>).actions += action;//将委托事件添加进去
|
|
}
|
|
else
|
|
{
|
|
eventDic.Add(name, new EventInfo<T,K>(action));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加事件监听
|
|
/// </summary>
|
|
/// <param name="name">事件名字</param>
|
|
/// <param name="action"> 事件 的委托函数</param>
|
|
public void AddEventListener<T>(string name, UnityAction<T> action)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
(eventDic[name] as EventInfo<T>).actions += action;//将委托事件添加进去
|
|
}
|
|
else
|
|
{
|
|
eventDic.Add(name, new EventInfo<T>(action));
|
|
}
|
|
}
|
|
public void AddEventListener(string name, UnityAction action)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
(eventDic[name] as EventInfo).actions += action;//将委托事件添加进去
|
|
}
|
|
else
|
|
{
|
|
eventDic.Add(name, new EventInfo(action));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 移出事件监听
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <param name="action"></param>
|
|
public void RemoveEnvetListener<T,K>(string name, UnityAction<T,K> action)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
(eventDic[name] as EventInfo<T,K>).actions -= action;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 移出事件监听
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <param name="action"></param>
|
|
public void RemoveEnvetListener<T>(string name, UnityAction<T> action)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
(eventDic[name] as EventInfo<T>).actions -= action;
|
|
}
|
|
}
|
|
public void RemoveEnvetListener(string name, UnityAction action)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
(eventDic[name] as EventInfo).actions -= action;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 执行事件触发
|
|
/// </summary>
|
|
/// <param name="name"> 事件名字</param>
|
|
public void EventTrigger<T>(string name, T info)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
|
|
//eventDic[name]();
|
|
//eventDic[name].Invoke();
|
|
if ((eventDic[name] as EventInfo<T>).actions != null)
|
|
(eventDic[name] as EventInfo<T>).actions.Invoke(info);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 执行事件触发
|
|
/// </summary>
|
|
/// <param name="name"> 事件名字</param>
|
|
public void EventTrigger<T,K>(string name, T info,K info1)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
|
|
//eventDic[name]();
|
|
//eventDic[name].Invoke();
|
|
if ((eventDic[name] as EventInfo<T,K>).actions != null)
|
|
(eventDic[name] as EventInfo<T,K>).actions.Invoke(info,info1);
|
|
}
|
|
}
|
|
public void EventTrigger(string name)
|
|
{
|
|
if (eventDic.ContainsKey(name))
|
|
{
|
|
|
|
//eventDic[name]();
|
|
//eventDic[name].Invoke();
|
|
if ((eventDic[name] as EventInfo).actions != null)
|
|
(eventDic[name] as EventInfo).actions.Invoke();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清空事件监听
|
|
/// </summary>
|
|
public void Clear()
|
|
{
|
|
eventDic.Clear();
|
|
}
|
|
}
|