Beispiel #1
0
 /// <summary>
 /// 注册对象的消息响应。
 /// 请及时调用UnRegister以取消注册,否则<paramref name="target"/>对象将不会被GC!
 /// </summary>
 public void Register(object target)
 {
     foreach (var method in ExecuteAttribute.GetInstanceExecuteMethod(target.GetType()))
     {
         RegisterMethod(method, target);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 静态消息响应函数
 /// </summary>
 public void StaticRegister()
 {
     foreach (var method in ExecuteAttribute.GetStaticExecuteMethod(Reflection.GetExecutingAssembly()))
     {
         RegisterMethod(method);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 静态消息响应函数
        /// </summary>
        public IEnumerator StaticRegisterAsync()
        {
#if UNITY_EDITOR
            var watch = new System.Diagnostics.Stopwatch();
            watch.Start();
#endif
            yield return(null);

            foreach (var method in ExecuteAttribute.GetStaticExecuteMethod(Reflection.GetExecutingAssembly()))
            {
                RegisterMethod(method);
                yield return(null);
            }
#if UNITY_EDITOR
            watch.Stop();
            UnityEngine.Debug.Log(string.Format("MessageDispatcher.StaticRegister: {0}s", watch.Elapsed.TotalSeconds));
#endif
        }