Esempio n. 1
0
        /// <summary>
        /// 创建一个新的或者复用存在的UITask
        /// </summary>
        /// <param name="uiTaskRegisterItem"></param>
        /// <returns></returns>
        private UITask CreateOrGetUITaskInstance(UITaskRegisterItem uiTaskRegisterItem)
        {
            UITask instance = null;

            if (uiTaskRegisterItem.AllowMultipleInstance)
            {
                //AllowMultipleInstance总是会创建出新的实例
                instance = ClassLoader.CreateInstance(uiTaskRegisterItem.TypeFullName, uiTaskRegisterItem.Name) as UITask;
                int instanceId = GetInstanceID(uiTaskRegisterItem.Name);
                instance.SetInstanceID(instanceId);
            }
            else
            {
                //复用之前的UITask
                List <UITask> uiTasks;
                m_uiTaskDic.TryGetValue(uiTaskRegisterItem.Name, out uiTasks);
                if (uiTasks != null && uiTasks.Count != 0)
                {
                    instance = uiTasks[0];
                }
                else
                {
                    //如果不存在,创建一个新的
                    instance = ClassLoader.CreateInstance(uiTaskRegisterItem.TypeFullName, uiTaskRegisterItem.Name) as UITask;
                }
            }
            return(instance);
        }
Esempio n. 2
0
 /// <summary>
 /// 注册UITask条目
 /// </summary>
 /// <param name="uiTaskRegisterItem"></param>
 public void RegisterUITask(UITaskRegisterItem uiTaskRegisterItem)
 {
     if (string.IsNullOrEmpty(uiTaskRegisterItem.Name))
     {
         Debug.LogError("uiTaskRegisterItem's name is null or empty");
         return;
     }
     if (m_uiTaskRegistyerItemDic.ContainsKey(uiTaskRegisterItem.Name))
     {
         Debug.LogError("RegisterUITask, Already contain the same name UITask,name:" + uiTaskRegisterItem.Name);
         return;
     }
     m_uiTaskRegistyerItemDic.Add(uiTaskRegisterItem.Name, uiTaskRegisterItem);
 }