Example #1
0
 /// <summary>
 /// 获取某个界面控制
 /// </summary>
 /// <param name="uiInstanceID"></param>
 /// <returns></returns>
 public BaseUIController GetUIController(UIInstanceIDEnum uiInstanceID)
 {
     if (m_AllInstantiateUI.ContainsKey(uiInstanceID))
     {
         return(m_AllInstantiateUI[uiInstanceID]);
     }
     return(null);
 }
Example #2
0
    /// <summary>
    /// 判断界面是否显示
    /// </summary>
    /// <param name="ui">ui的对象</param>
    /// <returns></returns>
    public bool IsShowUI(UIInstanceIDEnum uiInstanceID)
    {
        if (m_AllInstantiateUI.ContainsKey(uiInstanceID))
        {
            return(m_AllInstantiateUI[uiInstanceID].View.isShowState);
        }

        LogManager.LogError("没有找到对应UI界面的ID:" + (int)uiInstanceID);
        return(false);
    }
Example #3
0
 /// <summary>
 /// 注册UI界面
 /// </summary>
 public void RegisterUI(UIInstanceIDEnum uIInstanceID)
 {
     if (!m_AllRegisterUI.Contains(uIInstanceID))
     {
         m_AllRegisterUI.Add(uIInstanceID);
     }
     else
     {
         LogManager.LogError("重复注册界面:" + uIInstanceID);
     }
 }
Example #4
0
 /// <summary>
 /// 隐藏UI界面
 /// </summary>
 /// <param name="ui"></param>
 public void Hide(UIInstanceIDEnum uiInstanceID)
 {
     if (m_AllRegisterUI.Contains(uiInstanceID))           //如果界面有注册
     {
         if (m_AllInstantiateUI.ContainsKey(uiInstanceID)) //如果界面生成过
         {
             BaseUIView view = m_AllInstantiateUI[uiInstanceID].View;
             view.OnHide();
             BaseUIController controller = view.GetComponent <BaseUIController>();
             controller.OnHide();
             view.gameObject.SetActive(false);
         }
     }
     else
     {
         LogManager.LogError("显示没有注册的界面:" + uiInstanceID);
     }
 }
Example #5
0
 /// <summary>
 /// 显示UI
 /// </summary>
 /// <param name="uiInstanceID">UI唯一实例ID</param>
 /// <param name="uiGameObject">UI界面游戏物体</param>
 /// <param name="args">传递参数</param>
 public void ShowUI(UIInstanceIDEnum uiInstanceID, object args = null)
 {
     if (m_AllRegisterUI.Contains(uiInstanceID))                              //如果界面有注册
     {
         if (!m_AllInstantiateUI.ContainsKey((UIInstanceIDEnum)uiInstanceID)) //如果界面没有生成过
         {
             //根据界面枚举找到对应加载预制体的路径
             //todo:这边应该是配置单独的模块进行配置加载和读取,而不是和其他关联
             //if (FarmGameManager.Instance.m_UIPathConfig == null)
             //{
             //    LogManager.LogError("没有读取到界面配置");
             //    return;
             //}
             //foreach (var item in FarmGameManager.Instance.m_UIPathConfig.allUIPath)
             //{
             //    if (item.id == (int)uiInstanceID)
             //    {
             //        LogManager.Log("path=" + item.path);
             //        GameObject uiGameObject = ResourceLoadManager.Instance.Load(item.path) as GameObject;
             //        BaseUIView view = Instantiate(uiGameObject).GetComponent<BaseUIView>();
             //        view.UIInstanceID = (int)uiInstanceID;
             //        view.OnCreated(args);
             //        view.OnShow(args);
             //        BaseUIController controller = view.GetComponent<BaseUIController>();
             //        controller.OnCreated(args);
             //        controller.OnShow(args);
             //todo:在这边也进行model层的初始化
             //        m_AllInstantiateUI.Add((UIInstanceIDEnum)view.UIInstanceID, controller);
             //    }
             //}
         }
         else//已经生成过界面
         {
             BaseUIView view = m_AllInstantiateUI[uiInstanceID].View;
             view.OnShow(args);
             BaseUIController controller = view.GetComponent <BaseUIController>();
             controller.OnShow(args);
         }
     }
     else
     {
         LogManager.LogError("显示没有注册的界面:" + uiInstanceID);
     }
 }