public void OpenUIForms(params string[] uiFormNames) { for (int i = 0; i < uiFormNames.Length; i++) { string uiFormName = uiFormNames[i]; if (m_DicOpenUIForms.ContainsKey(uiFormName)) { continue; } UIConfigData uiInfo = uIConfig.GetDataByKey(uiFormName); if (uiInfo == null) { Debug.LogWarning(GetType() + "/OpenUIForms()/ui is null! uiFormName:" + uiFormName); return; } if (m_DicAllUIForms.ContainsKey(uiFormName)) { openUIForm(uiFormName); } else { m_DicAllUIForms.Add(uiFormName, null); loadUIForm(uiInfo, uiFormName); } } }
private void ChangeUIFormState(string uiFormName, UIFormState state) { UIConfigData uiInfo = uIConfig.GetDataByKey(uiFormName); UIFormShowMode uIFormShowMode = (UIFormShowMode)uiInfo.UIFormShowMode; if (uIFormShowMode == UIFormShowMode.HideOther) { if (state == UIFormState.Open) { HideOpenUIForms(); } if (state == UIFormState.Close) { DisplayOpenUIForms(); } } else if (uIFormShowMode == UIFormShowMode.ReverseChange) { if (state == UIFormState.Open) { PushUIFormToStack(uiFormName); } if (state == UIFormState.Close) { ExitUIFormToStack(); } } dicUIFormState[uiFormName] = state; }
private void loadUIForm(UIConfigData uiInfo, string uiFormName) { Transform parent = null; switch ((UIFormDepth)uiInfo.UIFormsDepth) { case UIFormDepth.Normal: parent = m_TraNormal; break; case UIFormDepth.Fixed: parent = m_TraFixed; break; case UIFormDepth.PopUp: parent = m_TraPopUp; break; case UIFormDepth.Notice: parent = m_TraNotice; break; } UIParam uiParam = new UIParam(); uiParam.uIFormDepth = (UIFormDepth)uiInfo.UIFormsDepth; uiParam.uIFormShowMode = (UIFormShowMode)uiInfo.UIFormShowMode; if ((LoadType)uiInfo.LandType == LoadType.Resources) { GameObject prefab = ResoucesMgr.Instance.Load <GameObject>(uiInfo.ResourcesPath, false); loadUIFormFinish(uiFormName, prefab, parent, uiParam); } else if ((LoadType)uiInfo.LandType == LoadType.AssetBundle) { AssetBundleMgr.Instance.LoadAssetBunlde("UI", uiInfo.AssetBundlePath); GameObject prefab = AssetBundleMgr.Instance.LoadAsset("UI", uiInfo.AssetBundlePath, uiInfo.AssetName) as GameObject; loadUIFormFinish(uiFormName, prefab, parent, uiParam); } }
private void InitUIConfigs() { string datastr = Resources.Load <TextAsset>("UIConfig/UIConfig").text; UIConfigDatas datas = JsonUtility.FromJson <UIConfigDatas>(datastr); for (int i = 0; i < datas.Datas.Length; i++) { UIConfigData data = datas.Datas[i]; _dicUIConfigs.Add((UIType)data.uiType, data); } }
private void InitState() { dicUIFormState.Clear(); for (int i = 0; i < uIConfig.GetCount(); i++) { UIConfigData uiInfo = uIConfig.GetAllData()[i]; if (!dicUIFormState.ContainsKey(uiInfo.Name)) { ChangeUIFormState(uiInfo.Name, UIFormState.None); } } }
private BaseView CreateView(UIType uiType, bool isReapt = false) { if (!_dicUIConfigs.ContainsKey(uiType)) { Debug.LogError(string.Format("请在UIType={0},是否在UIConfig.json中配置!", uiType)); return(null); } BaseView curView; UIConfigData uiConfig = _dicUIConfigs[uiType]; //1、判断是否时可重复的View if (!isReapt) { //如果不是可重复界面,那么将当前打开的这个类型的界面全都关闭 CloseView(uiType, true); } //2、判断打开的是不是固定界面 if ((UILayer)uiConfig.uiLayer == UILayer.Fixed) { CloseAllView(); } //3、判断是否有缓存 curView = PopViewFromCache(uiType); if (curView == null) { //创建新的View Transform parent = GetChildLayer((UILayer)uiConfig.uiLayer); GameObject prefab = Resources.Load <GameObject>(uiConfig.prefabPath); curView = GameObject.Instantiate <GameObject>(prefab, parent, false).GetComponent <BaseView>(); } //4、生成新的ViewId,添加界面 curView.InitViewAttribute(++_instanceViewID, uiConfig); AddChildToLayer(curView); //5、更新_curTopViewID BaseView topView = GetTopView(); if (topView) { _curTopViewID = topView.GetViewID(); } return(curView); }
private void LoadUIForm(UIConfigData uiInfo, string uiFormName) { Transform parent = null; switch ((UIFormDepth)uiInfo.UIFormsDepth) { case UIFormDepth.Normal: parent = traNormal; break; case UIFormDepth.Fixed: parent = traFixed; break; case UIFormDepth.PopUp: parent = traPopUp; break; case UIFormDepth.Notice: parent = traNotice; break; } UIParam uiParam = new UIParam(); uiParam.UIFormsDepth = (UIFormDepth)uiInfo.UIFormsDepth; uiParam.UIFormsShowMode = (UIFormShowMode)uiInfo.UIFormShowMode; if ((LoadType)uiInfo.LandType == LoadType.Resources) { GameObject prefab = ResoucesMgr.Instance.Load <GameObject>(uiInfo.ResourcesPath, false); LoadUIFormFinish(uiFormName, prefab, parent, uiParam); } else if ((LoadType)uiInfo.LandType == LoadType.AssetBundle) { AbParam abParam = new AbParam(); abParam.SceneName = "UI"; abParam.AbName = uiInfo.AssetBundlePath; abParam.AssetName = uiInfo.AssetName; AssetManager.Instance.LoadAsset(abParam, (error, asset) => { if (string.IsNullOrEmpty(error)) { LoadUIFormFinish(uiFormName, asset as GameObject, parent, uiParam); } else { LoadUIFormFinish(uiFormName, null, parent, uiParam); } }); } }
public void OpenUIForms(params string[] uiFormNames) { for (int i = 0; i < uiFormNames.Length; i++) { string uiFormName = uiFormNames[i]; if (dicOpenUIForms.ContainsKey(uiFormName)) { continue; } UIConfigData uiInfo = uIConfig.GetDataByKey(uiFormName); if (uiInfo == null) { Debug.LogWarning(GetType() + "/OpenUIForms()/ Open ui error! ui is null! uiFormName:" + uiFormName); return; } if (dicAllUIForms.ContainsKey(uiFormName)) { if (dicAllUIForms[uiFormName] != null) { dicAllUIForms[uiFormName].gameObject.SetActive(true); } if (dicAllUIForms[uiFormName] != null) { dicOpenUIForms.Add(uiFormName, dicAllUIForms[uiFormName]); } BaseUIForm baseUIForm = dicAllUIForms[uiFormName].gameObject.GetComponent <BaseUIForm>(); if (baseUIForm != null) { baseUIForm.OnOpenUI(); } } else { dicAllUIForms.Add(uiFormName, null); LoadUIForm(uiInfo, uiFormName); } } }