public int ShowDialog(DialogType type, string text, string okButton = "OK", string cancelButton = "Cancel", CommonDialog.DelegateButtonPressed buttonDelegate = null, CommonDialog.DialogPriority priority = CommonDialog.DialogPriority.Common) { CommonDialog dialog = CreateCommonDialogInstance(DialogNames[( int )type]); if (dialog != null) { DialogStatus status = new DialogStatus(IdCounter++); ButtonDelegate = buttonDelegate; dialog.Show(status.Id, text, okButton, cancelButton, OnButtonPressed, priority); DialogStatusList.Add(status); return(status.Id); } return(-1); }
public static CommonDialog ShowCommonDialog(Action <int> action, string dialogName, Action <CommonDialog> actionReady) { bool flag = true; float aT = 0.2f; float x2 = 0f; float y = 0f; float sizeX = -1f; float sizeY = -1f; if (!GUIManager.commonDialogs.ContainsKey(dialogName)) { string path = "UIDialogBox/" + dialogName; GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(Resources.Load(path, typeof(GameObject))); if (null == gameObject) { return(null); } Vector3 localScale = gameObject.transform.localScale; gameObject.transform.parent = Singleton <GUIManager> .Instance.gameObject.transform; gameObject.transform.localScale = localScale; gameObject.SetActive(true); if (!GUIManager.commonDialogs.ContainsKey(dialogName)) { return(null); } } else if (GUIManager.commonDialogs[dialogName].gameObject.activeSelf) { return(GUIManager.commonDialogs[dialogName]); } Action <int> action2 = delegate(int x) { GUIManager.dialogValue_ = x; }; if (action != null) { action2 = (Action <int>)Delegate.Combine(action2, action); } CommonDialog commonDialog = GUIManager.commonDialogs[dialogName]; Vector3 position = commonDialog.gameObject.transform.position; commonDialog.gameObject.transform.localPosition = new Vector3(x2, y, position.z); if (actionReady != null) { actionReady(commonDialog); } commonDialog.Show(action2, sizeX, sizeY, aT); GUIManager.blockBGCollider = flag; if (GUIManager.blockBGCollider) { GUIManager.ShowGUI("CommonDialogBarrier"); } CommonDialog topDialog = GUIManager.GetTopDialog(commonDialog, false); Vector3 localPosition = commonDialog.gameObject.transform.localPosition; float num; if (!commonDialog.dontManageZPos) { if (topDialog == null) { num = GUIManager.DLG_START_Z; } else { num = topDialog.gameObject.transform.localPosition.z + GUIManager.DLG_PITCH_Z; } localPosition.z = num; } else { num = localPosition.z; } commonDialog.SetOriginalPos(localPosition); GUIBase guibase = GUIManager.guiBases["CommonDialogBarrier"]; localPosition = guibase.gameObject.transform.localPosition; localPosition.x = (localPosition.y = 0f); localPosition.z = num + GUIManager.DLG_BARRIER_OFS_Z; guibase.gameObject.transform.localPosition = localPosition; UISprite component = guibase.gameObject.GetComponent <UISprite>(); if (component != null) { component.color = commonDialog.barrierColor; } if (GUIMain.USE_NGUI) { UIWidget component2 = guibase.gameObject.GetComponent <UIWidget>(); if (component2 != null) { component2.depth = (int)(-(int)guibase.gameObject.transform.localPosition.z); } int add = (int)(-(int)commonDialog.gameObject.transform.localPosition.z); GUIManager.AddWidgetDepth(commonDialog.gameObject.transform, add); } if (GUIManager.actCallShowDialog != null) { GUIManager.actCallShowDialog(commonDialog); } return(commonDialog); }