public void LoadDialog(string key, System.Action <UIDialogBase> callback) { UIDialogBase dialog = FindDialogInCache(key); if (dialog == null) { string assetName = key + "Dialog"; string abName = AppConst.ResDir + "Prefabs/UI/Dialog/" + assetName + ".prefab"; ResManager.LoadPrefab(abName, delegate(UnityEngine.Object[] objs) { if (objs.Length == 0) { return; } GameObject newSceneGameObject = objs[0] as GameObject; if (newSceneGameObject != null) { newSceneGameObject = UIUtils.AddChild(DialogRoot, newSceneGameObject); if (newSceneGameObject.activeSelf == true) { Debug.Log("newSceneGameObject activity true:" + newSceneGameObject.name); } else { Debug.Log("newSceneGameObject activity false:" + newSceneGameObject.name); } if (newSceneGameObject != null) { dialog = newSceneGameObject.GetComponent <UIDialogBase>(); dialog.InitializeScene(); callback(dialog); } else { Debug.LogWarning("UISystem::LoadDialog() Failed to add new scene to parent UISystem with name: " + key); } } else { Debug.LogWarning("UISystem::LoadDialog() Failed to load new scene with name: " + key); } }); } else { callback(dialog); } }
/// <summary> /// 加载UI界面 /// </summary> /// <param name="strPrefabePath"></param> /// <returns></returns> public UIDialogBase LoadScene(string strPrefabePath) { UIDialogBase dialog = FindInCache(strPrefabePath); if (dialog == null) { GameObject newSceneGameObject = Resources.Load <GameObject>(strPrefabePath); if (newSceneGameObject != null) { newSceneGameObject = UIUtils.AddChild(this.gameObject, newSceneGameObject); if (newSceneGameObject != null) { dialog = newSceneGameObject.GetComponent <UIDialogBase>(); if (dialog == null) { newSceneGameObject.name = newSceneGameObject.name.Replace("(Clone)", ""); dialog = PPPUIBase.addScript(newSceneGameObject, newSceneGameObject.name) as UIDialogBase; } if (dialog != null) { dialog.name = strPrefabePath; dialog.InitializeScene(); } } else { PPP.pppShow(true, "UISystem::LoadDialog() Failed to add new scene to parent UISystem with name: " + strPrefabePath); } } else { PPP.pppShow(true, "UISystem::LoadDialog() Failed to load new scene with name: " + strPrefabePath); } } return(dialog); }
public UIDialogBase LoadScene(UIDialog key) { UIDialogBase dialog = FindInCache(key); if (dialog == null) { string strPrefabeName = Utils.GetEnumDes(key); GameObject newSceneGameObject = Resources.Load(strPrefabeName) as GameObject; if (newSceneGameObject != null) { newSceneGameObject = UIUtils.AddChild(this.gameObject, newSceneGameObject); if (newSceneGameObject.activeSelf == true) { Debug.Log("newSceneGameObject activity true:" + newSceneGameObject.name); } else { Debug.Log("newSceneGameObject activity false:" + newSceneGameObject.name); } if (newSceneGameObject != null) { dialog = newSceneGameObject.GetComponent <UIDialogBase>(); dialog.InitializeScene(); } else { Debug.LogWarning("UISystem::LoadDialog() Failed to add new scene to parent UISystem with name: " + key); } } else { Debug.LogWarning("UISystem::LoadDialog() Failed to load new scene with name: " + key); } } return(dialog); }