private void LoadUIFormFinish(string uiFormName, GameObject prefab, Transform parent, UIParam uiParam) { if (prefab == null) { ChangeUIFormState(uiFormName, UIFormState.Error); if (dicAllUIForms.ContainsKey(uiFormName)) { dicAllUIForms.Remove(uiFormName); } Debug.LogWarning(GetType() + "/LoadUIForm()/ load ui error! uiFormName:" + uiFormName); return; } if (dicUIFormState[uiFormName] == UIFormState.Loading) { ChangeUIFormState(uiFormName, UIFormState.Open); } GameObject item = Instantiate(prefab, parent); item.name = uiFormName; UIFormItem uIFormItem = item.GetComponent <UIFormItem>(); if (uIFormItem == null) { uIFormItem = item.AddComponent <UIFormItem>(); } uIFormItem.CurrentUIParam = uiParam; dicAllUIForms[uiFormName] = uIFormItem; Type type = Type.GetType(uiFormName); BaseUIForm baseUIForm = item.GetComponent <BaseUIForm>(); if (type != null && baseUIForm == null) { item.AddComponent(type); } item.SetActive(dicUIFormState[uiFormName] == UIFormState.Open); if (!dicOpenUIForms.ContainsKey(uiFormName) && (dicUIFormState[uiFormName] == UIFormState.Open || dicUIFormState[uiFormName] == UIFormState.Disable)) { dicOpenUIForms.Add(uiFormName, uIFormItem); } }
private void loadUIFormFinish(string uiFormName, GameObject prefab, Transform parent, UIParam uiParam) { if (prefab == null) { if (m_DicAllUIForms.ContainsKey(uiFormName)) { m_DicAllUIForms.Remove(uiFormName); } Debug.LogWarning(GetType() + "/loadUIForm()/ load ui error! uiFormName:" + uiFormName); return; } GameObject item = Instantiate(prefab, parent); item.name = uiFormName; UIFormItem uIFormItem = item.GetComponent <UIFormItem>(); if (uIFormItem == null) { uIFormItem = item.AddComponent <UIFormItem>(); } uIFormItem.CurrentUIParam = uiParam; m_DicAllUIForms[uiFormName] = uIFormItem; Type type = Type.GetType(uiFormName); if (type != null && item.GetComponent <BaseUIForm>() == null) { item.AddComponent(type); } BaseUIForm baseUIForm = item.GetComponent <BaseUIForm>(); if (baseUIForm != null) { baseUIForm.uIFormsDepth = uIFormItem.CurrentUIParam.uIFormDepth; baseUIForm.uIFormShowMode = uIFormItem.CurrentUIParam.uIFormShowMode; } if (!m_DicOpenUIForms.ContainsKey(uiFormName)) { openUIForm(uiFormName); } }
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); } } }
private void openUIForm(string uiFormName) { if (m_DicAllUIForms[uiFormName] != null) { m_DicAllUIForms[uiFormName].gameObject.SetActive(true); } if (m_DicAllUIForms[uiFormName] != null) { m_DicOpenUIForms.Add(uiFormName, m_DicAllUIForms[uiFormName]); } BaseUIForm baseUIForm = m_DicAllUIForms[uiFormName].gameObject.GetComponent <BaseUIForm>(); if (baseUIForm != null) { if (baseUIForm.uIFormShowMode == UIFormShowMode.ReverseChange && !m_DicReverseChangeUIForms.ContainsKey(uiFormName)) { m_DicReverseChangeUIForms.Add(uiFormName, baseUIForm); refreshReverseChangeUIForms(); } if (baseUIForm.uIFormShowMode == UIFormShowMode.FreezeOther && !m_DicFreezeOtherUIForms.ContainsKey(uiFormName)) { m_DicFreezeOtherUIForms.Add(uiFormName, baseUIForm); } if ((baseUIForm.uIFormsDepth == UIFormDepth.PopUp || baseUIForm.uIFormsDepth == UIFormDepth.Notice) && baseUIForm.uIFormShowMode != UIFormShowMode.FreezeOther && baseUIForm.uIFormShowMode != UIFormShowMode.Toast && !m_DicOpenUIFormsStack.ContainsKey(uiFormName)) { m_DicOpenUIFormsStack.Add(uiFormName, baseUIForm); } if (baseUIForm.uIFormShowMode == UIFormShowMode.HideOther) { HideOther(uiFormName); } baseUIForm.OnOpenUIEvent(); } }
public void CloseUIForms(params string[] uiFormNames) { for (int i = 0; i < uiFormNames.Length; i++) { string uiFormName = uiFormNames[i]; if (dicOpenUIForms.ContainsKey(uiFormName)) { if (dicOpenUIForms[uiFormName] != null) { dicOpenUIForms[uiFormName].gameObject.SetActive(false); } dicOpenUIForms.Remove(uiFormName); BaseUIForm baseUIForm = dicAllUIForms[uiFormName].gameObject.GetComponent <BaseUIForm>(); if (baseUIForm != null) { baseUIForm.OnCloseUI(); } } } }