public static PopupDialogView PopupAB(PopupDialogType t, AssetBundle bundle, GameObject parent, string richPath, object[] richPs, ButtonEventHandler callback, params object[] ps) { if (null == NGUI2DRootPanel.Inst) { return(null); } #if SDK_HM PlatformSDKInterface.LoginLocked = false; #endif for (int i = 0; i < mShowDialogs.Count; ++i) { if ((t == mShowDialogs[i].DialogType || mShowDialogs[i].关联类型.Contains(t)) && mShowDialogs[i].唯一) { if (mShowDialogs[i].唯一等待) { mWaitShowDialogs.Add(new object[] { t, parent, richPath, richPs, callback, ps }); } return(mShowDialogs[i]); } } if (null == parent) { parent = NGUI2DRootPanel.Inst.gameObject; } PopupDialogView dialog = null; string dialogName = "Popup_" + t.ToString(); dialogName = dialogName.ToLower(); GameObject dialogObj = bundle.LoadAsset <GameObject>(dialogName); if (null == dialogObj) { return(null); } GameObject dlg = Instantiate(dialogObj); dialog = dlg.GetComponent <PopupDialogView>(); if (null != dialog) { OnDialogLoadOvered(t, dialog, parent.transform, richPath, richPs, callback, ps); } //bundle.Unload(false); //bundle = null; dialogObj = null; Resources.UnloadUnusedAssets(); dialog.FadeIn(); return(dialog); }
public static PopupDialogView Popup(PopupDialogType t, GameObject parent, string richPath, object[] richPs, ButtonEventHandler callback, params object[] ps) { if (null == NGUI2DRootPanel.Inst) { return(null); } #if SDK_HM PlatformSDKInterface.LoginLocked = false; #endif for (int i = 0; i < mShowDialogs.Count; ++i) { if ((t == mShowDialogs[i].DialogType || mShowDialogs[i].关联类型.Contains(t)) && mShowDialogs[i].唯一) { if (mShowDialogs[i].唯一等待) { mWaitShowDialogs.Add(new object[] { t, parent, richPath, richPs, callback, ps }); } return(mShowDialogs[i]); } } if (null == parent) { parent = NGUI2DRootPanel.Inst.gameObject; } PopupDialogView dialog = null; string dialogName = PrefixName + t.ToString(); GameObject dialogObj = Resources.Load(dialogName) as GameObject; if (null == dialogObj) { return(null); } GameObject dlg = Instantiate(dialogObj); dialog = dlg.GetComponent <PopupDialogView>(); if (null != dialog) { OnDialogLoadOvered(t, dialog, parent.transform, richPath, richPs, callback, ps); } dialogObj = null; Resources.UnloadUnusedAssets(); dialog.FadeIn(); // string atlasList = LogicModel.GetResName(ResourceType.UINeedAtlas, dialogName); // dialog = UIResourceManager.LoadUIDialog(dialogName, atlasList, t, parent.transform, richPath, richPs, callback, ps, OnDialogLoadOvered); return(dialog); }
void CheckDialogClose() { if (mShowDialogs.Contains(this)) { mShowDialogs.Remove(this); } for (int i = 0; i < mWaitShowDialogs.Count; ++i) { object[] ps = mWaitShowDialogs[i]; if (DialogType == (PopupDialogType)ps[0]) { if (null != PopupDialogView.Popup((PopupDialogType)ps[0], ps[1] as GameObject, ps[2] as string, ps[3] as object[], ps[4] as ButtonEventHandler, ps[5] as object[])) { mWaitShowDialogs.RemoveAt(i); break; } } } }
public static void OnDialogLoadOvered(PopupDialogType t, PopupDialogView view, Transform parent, string richPath, object[] richPs, ButtonEventHandler callback, object[] ps) { if (null != view) { view.transform.parent = parent; view.transform.localScale = UnityEngine.Vector3.one; view.transform.localPosition = UnityEngine.Vector3.zero; view.transform.localRotation = Quaternion.identity; view.UI类型 = UIViewType.弹出框; if (null != view.内容 && !string.IsNullOrEmpty(richPath)) { view.内容.地址 = richPath; view.内容.SetParam(richPs); } // if (ItemGridsViewPanel.InstCount > 0) // { // Camera cam = ItemGridsViewPanel.Inst.RenderTargetUpperRoot.GetComponentInChildren<Camera>(); // UIAnchor anchor = view.GetComponent<UIAnchor>(); // if (null != anchor) // anchor.uiCamera = cam; // UIAnchor[] anchors = view.GetComponentsInChildren<UIAnchor>(); // for (int i = 0; i < anchors.Length; ++i) // anchors[i].uiCamera = cam; // } } switch (t) { case PopupDialogType.Confirm: case PopupDialogType.CancelOrConfirm: { if (null != view) { int index = 0; if (ps.Length >= 1) { if (ps.Length >= 2) { if (!(ps[index] is string)) { view.标题.text = ps[index].ToString(); } else { view.标题.text = ps[index] as string; } index++; } if (ps[index] is string && !string.IsNullOrEmpty(ps[index] as string)) { if (null != view.内容) { if (!(ps[index] is string)) { view.内容.SetText(ps[index].ToString()); } else { view.内容.SetText(ps[index] as string); } } if (null != view.内容1) { if (!(ps[index] is string)) { view.内容1.text = ps[index].ToString(); } else { view.内容1.text = ps[index] as string; } } index++; } if (ps.Length >= index + 1) { string[] btnText = ps[index] as string[]; if (null != btnText) { int btnIndex = 0; if (null != view.钮1 && btnIndex < btnText.Length) { view.钮1.text = btnText[btnIndex++] as string; } if (null != view.钮2 && btnIndex < btnText.Length) { view.钮2.text = btnText[btnIndex++] as string; } if (null != view.钮3 && btnIndex < btnText.Length) { view.钮3.text = btnText[btnIndex++] as string; } index++; } } if (ps.Length >= index + 1) { if (ps[index] is float) { view.倒计时 = (float)ps[index]; index++; } } if (ps.Length >= index + 1) { if (ps[index] is object[]) { view.SetParam(ps[index] as object[]); } else { List <object> psList = new List <object>(); for (int i = index; i < ps.Length; ++i) { psList.Add(ps[i]); } view.SetParam(psList.ToArray() as object[]); } } } } } break; default: { if (null != view) { view.SetParam(ps); } } break; } if (null != view) { if (null != callback) { view.OnButtonClicked += new ButtonEventHandler(callback); } view.DialogType = t; //if (view.唯一) mShowDialogs.Add(view); } }