private void LoadUIFormFinish(string uiFormName, GameObject prefab, Transform parent, UIParam uiParam) { if (prefab == null) { if (dicAllUIForms.ContainsKey(uiFormName)) { 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; 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.OnOpenUI(); } item.SetActive(true); if (!dicOpenUIForms.ContainsKey(uiFormName)) { dicOpenUIForms.Add(uiFormName, uIFormItem); } }
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); } } }