当前位置:网站首页>One of event management
One of event management
2022-04-23 07:47:00 【youth who behaves like an adult】
public enum EUIMgrEvent
{
onUILogInOpend,
onUILogInClose,
onUIHintOpend,
onUIHintClose,
onUIWorkOpend,
onUIWorkClose,
onUIShopOpend,
onUIShopClose
}
First create several event types , Then add the event type , Trigger , Delete and other operations ..........
1. Create a dictionary to save events
Dictionary<EUIMgrEvent, Action<object, object[]>> _phList = new Dictionary<EUIMgrEvent, Action<object, object[]>>();
2. Add event
public void addEventHandler(EUIMgrEvent eventID,Action<object, object[]> handler)
{
if (_phList == null) return;
if (_phList.ContainsKey(eventID))
{
Debug.LogError(string.Format("error: event[ {0} ] already exists", eventID));
return;
}
_phList[eventID] = handler;
}
3. Delete event
public void delEventHandler(EUIMgrEvent eventID)
{
if (_phList == null) return;
if (!_phList.ContainsKey(eventID))
{
Debug.LogError(string.Format("error: event[ {0} ] not exists", eventID));
return;
}
_phList.Remove(eventID);
}
4. Triggering event
public void fireEvent(EUIMgrEvent eventID,object sender ,object[] args)
{
if (_phList == null) return;
if (!_phList.ContainsKey(eventID)){
return;
}
var action = _phList[eventID];
if (action == null) return;
action(sender, args);
}
5. Reset event system
public void Reset()
{
if (_phList == null) return;
_phList.Clear();
_phList = null;
}
版权声明
本文为[youth who behaves like an adult]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230626191374.html
边栏推荐
- 7. sub query
- 命令行参数传递库argparse的使用
- SAP CR传输请求顺序、依赖检查
- Page dynamic display time (upgraded version)
- 对复杂字典Dictionary&lt;T1,T2&gt;排序问题
- RGB颜色转HEX进制与单位换算
- Methods of database query optimization
- Two threads print odd and even numbers interactively
- 如何判断点是否在多边形内(包含复杂多边形或者多边形数量很多的情况)
- SAP pi / PO rfc2restful publishing RFC interface is a restful example (proxy indirect method)
猜你喜欢
随机推荐
12. Constraints
自己封装unity的Debug函数
js之自定义属性以及H5中如何判断自定义属性
C# SmoothProgressBar自定义进度条控件
Implementation of MySQL persistence
快排的练习
移动布局(flex布局、视口标签)
Use of typescript dictionary
C#操作注册表全攻略
Custom time format (yyyy-mm-dd HH: mm: SS week x)
keytool: command not found
SAP Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃。
双面显示的shader
4. Multi table query
Methods of database query optimization
Judge whether the beginning and end of the string contain target parameters: startswith() and endswith() methods
NodeJS(六) 子进程操作
给定区段范围内字符串自生成代码
int a = 1存放在哪
设置了body的最大宽度,但是为什么body的背景颜色还铺满整个页面?