Unityeditor 事件(2)
来源:互联网 发布:鬼武者 知乎 编辑:程序博客网 时间:2024/06/08 03:44
1.创建一个 BaseCubes 类
using UnityEngine;using System.Collections.Generic;public class BaseCubes { private static List<Cubes> m_list = new List<Cubes>(); private static string eventName = "all"; public static void Resister(Cubes _cubes) { m_list.Add(_cubes); _cubes.AddListen(OnCallBack, eventName); } public static void OnCallBack() { Debug.Log("YY"); }}
2.注册一个添加简单监听函数
using UnityEngine;using System.Collections;using System;public class ReflectMessage : MonoBehaviour { public void AddListen(Func<Void> handler , string eventName) { GEventManager.addDispatcher(this,handler.Method,eventName); }}
3.基于BaseCubes的继承类
using UnityEngine;using System.Collections;public class Cubes : ReflectMessage { public void Awake() { BaseCubes.Resister(this); }}
4.简单事件输出信息
using UnityEngine;using System.Collections;using System.Reflection;public class GEventManager { public static void addDispatcher(ReflectMessage dispatcher, MemberInfo method, string eventName) { Debug.Log(dispatcher.GetType().Name);//继承类名字 Debug.Log(dispatcher.GetHashCode()); //同样类不同hashcode值 if(method.IsStatic) { Debug.Log(method.DeclaringType.GetHashCode());//同样值 Debug.Log(method.DeclaringType.Name);//基类名字 } }}
0 0
- Unityeditor 事件(2)
- UnityEditor 反射事件2
- UnityEditor 事件(1)
- UnityEditor 布局(window layout)
- UnityEditor<三>自定义窗口 案例2
- Unity编辑器UnityEditor基础(二)
- UnityEditor 热键
- 初涉UnityEditor
- UnityEditor(1)
- UnityEditor下文件操作方法汇总(Unity3D开发之二十四)
- 使用UnityEditor做工具
- UnityEditor常用函数
- UnityEditor.Callbacks中的OnOpenAssetAttribute
- UnityEditor 打开对应类
- UnityEditor Windows Event(3)
- UnityEditor Window Event
- UnityEditor的Selection类
- 解决 UnityEditor.AsyncHTTPClient:Done
- 220. Contains Duplicate III
- 神经网络weight参数怎么初始化
- JAVASE--03--继承
- 数据库中表和视图的区别和联系
- 彻底弄懂JS的事件冒泡和事件捕获
- Unityeditor 事件(2)
- Django模板实现树状数据渲染
- boost 编写finger服务
- Java中的final关键字
- 图像处理算法(三)---图像常用操作
- mysql读写分离总结
- Spring中使用JdbcTemplate操作数据库
- Ubuntu下利用pip配置xgboost
- const理解