// 读表展示UI, public static bool ShowUIByID(int tableID, OnOpenUIDelegate delOpenUI = null, object param = null) { if (null == m_instance) { LogModule.ErrorLog("game manager is not init"); return(false); } Tab_UIPath curTabPath = TableManager.GetUIPathByID(tableID, 0); if (null == curTabPath) { LogModule.ErrorLog("cur ui is not set in table" + tableID); return(false); } if (!UIPathData.m_DicUIInfo.ContainsKey(curTabPath.Path)) { LogModule.ErrorLog("cur ui is not set in table" + curTabPath.Path); return(false); } UIPathData curData = UIPathData.m_DicUIInfo[curTabPath.Path]; return(UIManager.ShowUI(curData, delOpenUI, param)); }
public bool ShowUI(UIInfoData infoData, OnOpenUIDelegate delOpenUI = null, object param = null) { //已经显示了 if (UILayerManager.Instance.IsUIShow(infoData)) { Debug.Log("ShowUI :" + infoData.name + " already showed!"); return(true); } int refCount = AddLoadDicRefCount(infoData.name); //已经在加载 if (refCount > 1) { return(true); } //从缓存里面找,如果找到了,则直接进行显示 if (UILayerManager.Instance.IsConatain(infoData)) { Debug.Log("ShowUI :" + infoData.name + " already exist!"); GameObject uiGameObject = UILayerManager.Instance.GetUI(infoData); DoAddUI(infoData, uiGameObject, delOpenUI, param); return(true); } m_Instance.LoadUI(infoData, delOpenUI, param); return(true); }
public void LoadUI(UIData pathData, OnOpenUIDelegate delOpenUI = null, object param = null) { string str = "UI/" + pathData.path; GameObject curWindow = ResourcesManager.Load(str) as GameObject; if (curWindow != null) { DoShowUI(pathData, curWindow, delOpenUI, param); return; } }
/// <summary> /// 没有缓存的UI,进行加载 /// </summary> /// <param name="uiData"></param> /// <param name="delOpenUI"></param> /// <param name="param1"></param> void LoadUI(UIPathData uiData, OnOpenUIDelegate delOpenUI = null, object param1 = null) { GameObject curWindow = null; #if UNITY_ANDROID if (m_PrefabNameList != null && m_PrefabList != null) { if (m_PrefabNameList.Contains(uiData.name)) { if (m_PrefabList.ContainsKey(uiData.name)) { curWindow = m_PrefabList[uiData.name]; } } } #endif if (curWindow == null) { curWindow = ResourceManager.LoadResource("Prefab/UI/" + uiData.name) as GameObject; } //GameObject curWindow = ResourceManager.LoadResource("Prefab/UI/" + uiData.name) as GameObject; if (null != curWindow) { DoAddUI(uiData, curWindow, delOpenUI, param1); //LogModule.ErrorLog("can not open controller path not found:" + path); return; } if (uiData.uiGroupName != null) { GameObject objCacheBundle = BundleManager.GetGroupUIItem(uiData); if (null != objCacheBundle) { DoAddUI(uiData, objCacheBundle, delOpenUI, param1); return; } } #if UNITY_WP8 if (UIPathData.UIType.TYPE_POP == uiData.uiType || UIPathData.UIType.TYPE_MENUPOP == uiData.uiType) { m_UnloadItemBundle = true; } #endif StartCoroutine(BundleManager.LoadUI(uiData, DoAddUI, delOpenUI, param1)); }
public void ShowUI(UIData pathData, OnOpenUIDelegate delOpenUI = null, object parm = null) { Dictionary <string, BaseView> curDic = null; switch (pathData.uiType) { case UIData.UIType.TYPE_BASE: curDic = mDicBase; break; case UIData.UIType.TYPE_POP: curDic = mDicPop; break; case UIData.UIType.TYPE_DIALOG: curDic = mDicDialog; break; case UIData.UIType.TYPE_TIPS: break; case UIData.UIType.TYPE_TOP_BAR: curDic = mDicTop; break; } if (curDic == null) { return; } if (mDicCache.ContainsKey(pathData.name)) { if (!curDic.ContainsKey(pathData.name)) { curDic.Add(pathData.name, mDicCache[pathData.name]); } mDicCache.Remove(pathData.name); } if (curDic.ContainsKey(pathData.name)) { DoShowUI(pathData, curDic[pathData.name].gameObject, delOpenUI, parm); return; } LoadUI(pathData, delOpenUI, parm); }
public void ShowUIWithEnter(UIData pathData, OnOpenUIDelegate delOpen = null, object parm = null) { ShowUI(pathData, delegate(BaseView view, object param) { if (view != null) { view.OnEnter(parm, delegate { { if (delOpen != null) { delOpen(view, parm); } } }); } }, parm); }
void DoAddUI(IInfoData iData, GameObject curWindow, object fun, object param) { UIInfoData uiData = iData as UIInfoData; Debug.Log("DoAddUI:" + uiData.name); if (!m_dicWaitLoad.Remove(uiData.name)) { DestroyBundle(uiData.name); return; } UILayer.ShowUIResult showUIResult = UILayerManager.Instance.ShowUI(uiData, curWindow); if (showUIResult != UILayer.ShowUIResult.ErrorNotShowed) { if (null != fun) { OnOpenUIDelegate delOpenUI = fun as OnOpenUIDelegate; delOpenUI(curWindow != null, param); } } }
void DoAddUI(UIPathData uiData, GameObject curWindow, object fun, object param) { if (!m_dicWaitLoad.Remove(uiData.name)) { return; } if (null != curWindow) { #if UNITY_ANDROID if (m_PrefabNameList != null && m_PrefabList != null) { if (m_PrefabNameList.Contains(uiData.name)) { if (!m_PrefabList.ContainsKey(uiData.name)) { m_PrefabList.Add(uiData.name, curWindow); } else { if (m_PrefabList[uiData.name] == null) { m_PrefabList[uiData.name] = curWindow; } } } } #endif #if UNITY_ANDROID if (!PlatformHelper.IsChannelMainland()) { PushToOpenedList(uiData); } #endif Transform parentRoot = null; Dictionary <string, GameObject> relativeDic = null; switch (uiData.uiType) { case UIPathData.UIType.TYPE_BASE: parentRoot = BaseUIRoot; relativeDic = m_dicBaseUI; break; case UIPathData.UIType.TYPE_POP: parentRoot = PopUIRoot; relativeDic = m_dicPopUI; break; case UIPathData.UIType.TYPE_STORY: parentRoot = StoryUIRoot; relativeDic = m_dicStoryUI; break; case UIPathData.UIType.TYPE_TIP: parentRoot = TipUIRoot; relativeDic = m_dicTipUI; break; case UIPathData.UIType.TYPE_MENUPOP: parentRoot = MenuPopUIRoot; relativeDic = m_dicMenuPopUI; break; case UIPathData.UIType.TYPE_MESSAGE: parentRoot = MessageUIRoot; relativeDic = m_dicMessageUI; break; case UIPathData.UIType.TYPE_DEATH: parentRoot = DeathUIRoot; relativeDic = m_dicDeathUI; break; default: break; } if (uiData.uiType == UIPathData.UIType.TYPE_POP || uiData.uiType == UIPathData.UIType.TYPE_MENUPOP) { OnLoadNewPopUI(m_dicPopUI, uiData.name); OnLoadNewPopUI(m_dicMenuPopUI, uiData.name); } if (null != relativeDic && relativeDic.ContainsKey(uiData.name)) { relativeDic[uiData.name].SetActive(true); } else if (null != parentRoot && null != relativeDic) { GameObject newWindow = GameObject.Instantiate(curWindow) as GameObject; if (null != newWindow) { newWindow.transform.parent = parentRoot; newWindow.transform.localPosition = Vector3.zero; newWindow.transform.localScale = Vector3.one; relativeDic.Add(uiData.name, newWindow); //自动加的一个比较大的MenuSubUIShield,有个大collider。王喆说以后应该不用了 /*if (uiData.uiType == UIPathData.UIType.TYPE_MENUPOP) * { * LoadMenuSubUIShield(newWindow); * }*/ } } //if (uiData.uiType == UIPathData.UIType.TYPE_STORY) //{ // BaseUIRoot.gameObject.SetActive(false); // TipUIRoot.gameObject.SetActive(false); // PopUIRoot.gameObject.SetActive(false); // MenuPopUIRoot.gameObject.SetActive(false); // MessageUIRoot.gameObject.SetActive(false); // StoryUIRoot.gameObject.SetActive(true); //} //else if (uiData.uiType == UIPathData.UIType.TYPE_MENUPOP) if (uiData.uiType == UIPathData.UIType.TYPE_POP || (uiData.name == "BackPackRoot" && BackPackLogic.m_OpenWay == BackPackLogic.OPEN_WAY.NEWFUNCTION_QUICK) || (uiData.name == "RelationRoot" && RelationLogic.m_OpenWay == RelationLogic.OPEN_WAY.MISSION_TEAM)) { if (PlayerFrameLogic.Instance() != null) { PlayerFrameLogic.Instance().SwitchAllWhenPopUIShow(false); PlayerFrameLogic.Instance().gameObject.SetActive(false); } if (MenuBarLogic.Instance() != null) { MenuBarLogic.Instance().gameObject.SetActive(false); } if (!(uiData.name.Equals("ServerChooseController") || uiData.name.Equals("RoleCreate"))) { #if !UNITY_ANDROID StartCoroutine(GCAfterOneSceond()); #endif } } else if (uiData.uiType == UIPathData.UIType.TYPE_MENUPOP) { if (null != PlayerFrameLogic.Instance() && null != MenuBarLogic.Instance()) { MenuBarLogic.Instance().gameObject.SetActive(false); PlayerFrameLogic.Instance().gameObject.SetActive(false); #if !UNITY_ANDROID StartCoroutine(GCAfterOneSceond()); #endif } } else if (uiData.uiType == UIPathData.UIType.TYPE_DEATH) { ReliveCloseOtherSubUI(); } } if (null != fun) { OnOpenUIDelegate delOpenUI = fun as OnOpenUIDelegate; delOpenUI(curWindow != null, param); } }
// 展示UI,根据类型不同,触发不同行为 public static bool ShowUI(UIPathData pathData, OnOpenUIDelegate delOpenUI = null, object param = null) { if (null == m_instance) { LogModule.ErrorLog("game manager is not init"); return(false); } m_instance.AddLoadDicRefCount(pathData.name); #if !UNITY_EDITOR && !UNITY_STANDALONE_WIN if (pathData.uiType == UIPathData.UIType.TYPE_POP || // pathData.uiType == UIPathData.UIType.TYPE_STORY || // 现在对话界面有可能是小对话不需要释放摇杆了,把释放摇杆的操作放到具体逻辑中去 pathData.uiType == UIPathData.UIType.TYPE_TIP || pathData.uiType == UIPathData.UIType.TYPE_MENUPOP) { if (JoyStickLogic.Instance() != null) { ProcessInput.Instance().ReleaseTouch(); JoyStickLogic.Instance().ReleaseJoyStick(); } } #endif Dictionary <string, GameObject> curDic = null; switch (pathData.uiType) { case UIPathData.UIType.TYPE_BASE: curDic = m_instance.m_dicBaseUI; break; case UIPathData.UIType.TYPE_POP: curDic = m_instance.m_dicPopUI; break; case UIPathData.UIType.TYPE_STORY: curDic = m_instance.m_dicStoryUI; break; case UIPathData.UIType.TYPE_TIP: curDic = m_instance.m_dicTipUI; break; case UIPathData.UIType.TYPE_MENUPOP: curDic = m_instance.m_dicMenuPopUI; break; case UIPathData.UIType.TYPE_MESSAGE: curDic = m_instance.m_dicMessageUI; break; case UIPathData.UIType.TYPE_DEATH: curDic = m_instance.m_dicDeathUI; break; default: return(false); } if (null == curDic) { return(false); } if (m_instance.m_dicCacheUI.ContainsKey(pathData.name)) { if (!curDic.ContainsKey(pathData.name)) { curDic.Add(pathData.name, m_instance.m_dicCacheUI[pathData.name]); } m_instance.m_dicCacheUI.Remove(pathData.name); } if (curDic.ContainsKey(pathData.name)) { // 如果缓存区有,那么直接显示 curDic[pathData.name].SetActive(true); m_instance.DoAddUI(pathData, curDic[pathData.name], delOpenUI, param); return(true); } m_instance.LoadUI(pathData, delOpenUI, param); return(true); }
void DoShowUI(UIData pathData, GameObject curWindow, OnOpenUIDelegate delOpenUI, object parm = null) { if (curWindow == null) { if (delOpenUI != null) { delOpenUI(null, parm); } return; } BaseView view = null; Transform parent; Dictionary <string, BaseView> relativeDic = null; List <BaseView> mShowList = null; switch (pathData.uiType) { case UIData.UIType.TYPE_BASE: parent = BaseUIRoot.transform; relativeDic = mDicBase; mShowList = mShowViewList; break; case UIData.UIType.TYPE_DIALOG: parent = DialogUIRoot.transform; relativeDic = mDicDialog; mShowList = mShowDialogList; break; case UIData.UIType.TYPE_TIPS: parent = TipUIRoot.transform; relativeDic = mDicTip; break; case UIData.UIType.TYPE_TOP_BAR: parent = TopBarUIRoot.transform; mShowList = mShowTopBarList; relativeDic = mDicTop; break; case UIData.UIType.TYPE_POP: parent = PopUIRoot.transform; relativeDic = mDicPop; mShowList = mShowViewList; break; default: parent = UIRoot.list[0].transform; break; } if (relativeDic != null) { if (relativeDic.ContainsKey(pathData.name)) { view = relativeDic[pathData.name]; view.gameObject.transform.parent = parent; view.gameObject.transform.localScale = Vector3.one; view.gameObject.transform.localPosition = Vector3.zero; NGUITools.SetActive(view.gameObject, true); if (mShowList != null) { mShowList.Add(view); } } else { GameObject obj = MonoBehaviour.Instantiate(curWindow) as GameObject; obj.transform.parent = parent; obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; view = obj.GetComponent <BaseView>(); if (view != null) { view.CurUIData = pathData; relativeDic.Add(pathData.name, view); if (mShowList != null) { mShowList.Add(view); } } else { Debug.LogError("base view need script:" + pathData.name); } } } if (delOpenUI != null) { delOpenUI(view, parm); } }