private void Update() { try { if (queue.Count != 0 && !IsDialogActive) { DialogParameter parameter = queue.Dequeue(); UIDialogBase activeDialog = LoadScene(parameter._strPath); // 去加载这个UI界面 if (activeDialog != null) { openedList.Add(activeDialog); // 加到openedList里 activeDialog.transform.SetAsLastSibling(); activeDialog.OnSceneActivated(parameter._paras); // 场景打开的时候,把参数传递进去 } else { PPP.pppShow(); } } if (tipsQueue.Count != 0) { DialogParameter parameter = tipsQueue.Dequeue(); UIDialogBase dialog = LoadScene(parameter._strPath); dialog.transform.SetAsLastSibling(); dialog.OnSceneActivated(parameter._paras); } } catch (Exception ex) { PPP.pppShow(true, ex.ToString()); } }
public void CacheDialog(UIDialogBase dialog, bool isOk) { if (null != dialog) { openedDialogList.Remove(dialog); cacheDialogList.Add(dialog); } }
public void PushDialogImmediately(UIDialog dialog, params object[] paras) { DialogParameter parameter = new DialogParameter(dialog, paras); UIDialogBase activeDialog = LoadScene(parameter.dialog); openedList.Add(activeDialog); activeDialog.transform.SetAsLastSibling(); activeDialog.OnSceneActivated(parameter.paras); }
public void Cache(UIDialogBase dialog, bool isOk) { if (null != dialog) { openedList.Remove(dialog); cacheList.Add(dialog); if (null != OnDialogCallBack) { OnDialogCallBack(dialog.dialog, isOk); } } }
public void Cache(UIDialogBase dialog, bool isOk) { if (null != dialog) { openedList.Remove(dialog); if (!cacheList.Contains(dialog)) { cacheList.Add(dialog); } if (null != OnDialogCallBack) { OnDialogCallBack(dialog.name, isOk); } } }
/// <summary> /// 立刻加载UI界面 /// </summary> /// <param name="strPath"></param> /// <param name="paras"></param> /// <returns></returns> public UIDialogBase PushDialogImmediately(string strPath, params object[] paras) { DialogParameter parameter = new DialogParameter(strPath, paras); UIDialogBase activeDialog = LoadScene(parameter._strPath); if (activeDialog == null) { PPP.pppShow(); return(null); } openedList.Add(activeDialog); activeDialog.transform.SetAsLastSibling(); activeDialog.OnSceneActivated(parameter._paras); return(activeDialog); }
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); } }
public override void OnInspectorGUI() { UIDialogBase ui = (UIDialogBase)target; if (GUILayout.Button("设置引用对象")) { ui.SetAllMemberValue(); } EditorGUILayout.BeginHorizontal(); ui.UseBoxCollider = GUILayout.Toggle(ui.UseBoxCollider, "阻挡", "button", GUILayout.Width(35)); ui.UseBlackMask = GUILayout.Toggle(ui.UseBlackMask, "蒙版", "button", GUILayout.Width(35)); EditorGUILayout.EndHorizontal(); base.OnInspectorGUI(); }
private void Update() { if (queue.Count != 0 && !IsDialogActive) { DialogParameter parameter = queue.Dequeue(); UIDialogBase activeDialog = LoadScene(parameter.dialog); openedList.Add(activeDialog); activeDialog.transform.SetAsLastSibling(); activeDialog.OnSceneActivated(parameter.paras); } if (tipsQueue.Count != 0) { DialogParameter parameter = tipsQueue.Dequeue(); UIDialogBase dialog = LoadScene(parameter.dialog); dialog.transform.SetAsLastSibling(); dialog.OnSceneActivated(parameter.paras); } }
/// <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); }
/// <summary> /// 从缓存里找UI界面 /// </summary> /// <param name="key"></param> /// <returns></returns> UIDialogBase FindInCache(string key) { //foreach (UIDialogBase dialog in cacheList) //{ // if (dialog.name == key) // { // cacheList.Remove(dialog); // return dialog; // } //} // guoShuai 修改 for (int i = 0; i < cacheList.Count; i++) { if (cacheList[i].name == key) { UIDialogBase tmpDialog = cacheList[i]; cacheList.Remove(cacheList[i]); return(tmpDialog); } } return(null); }