Example #1
0
        /// <summary>
        /// 添加延迟调用函数
        /// </summary>
        /// <param name="handler">延迟调用函数</param>
        /// <param name="delayTime">延迟秒数</param>
        /// <param name="key">替换掉key相同 已有的handler</param>
        public static void Add(Action handler, float delayTime = 0.016f, string key = "")
        {
            if (delayTime <= 0)
            {
                handler();
                return;
            }
            if (delayTime < 0.016f)
            {
                delayTime = 0.016f;
            }

            if (string.IsNullOrEmpty(key) == false)
            {
                Action oldHandle;
                if (ActionMap.TryGetValue(key, out oldHandle))
                {
                    Remove(oldHandle);
                    ActionMap[key] = handler;
                }
                else
                {
                    ActionMap.Add(key, handler);
                }
            }

            Instance.add(delayTime, handler);
        }
 public static void Add(Action handler, float deleTime = 0)
 {
     instance.add(deleTime, handler);
 }