/// <summary> /// 打开对话框的同时显示提示信息,给按钮添加委托 /// </summary> /// <param name="msg"></param> /// <param name="okAction"></param> /// <param name="cancelAction"></param> public void Show(string msg, UIDialogType type = UIDialogType.OK, Action okAction = null, Action cancelAction = null) { if (mDialogObj == null) { mDialogObj = ResourcesManager.Instance.Load(ResourcesManager.ResourceType.UIPanel, "Panel_Dialog", isCache: true); } mDialogObj.transform.parent = UIRootController.Instance.currentScene.containerCenter; mDialogObj.transform.localPosition = Vector3.zero; mDialogObj.transform.localScale = Vector3.one; mDialogObj.GetComponent <RectTransform>().sizeDelta = Vector2.zero; //加挡板,防止点到后面的UI UIPanelDialogView view = mDialogObj.GetComponent <UIPanelDialogView>(); if (view != null) { view.Show(msg, okAction, cancelAction, type); } }
/// <summary> /// 打开对话框的同时显示提示信息,给按钮添加委托 /// </summary> /// <param name="msg"></param> /// <param name="okAction"></param> /// <param name="cancelAction"></param> public void Show(string msg, Action okAction, Action cancelAction, UIDialogType type = UIDialogType.OK) { gameObject.transform.localPosition = Vector3.zero; if (type == UIDialogType.OK) { //只有确定按钮 dialogCancelBtn.gameObject.SetActive(false); dialogOKBtn.transform.localPosition = Vector3.zero; } else { //有确定和取消2个按钮 dialogCancelBtn.gameObject.SetActive(true); dialogOKBtn.transform.localPosition = new Vector3(-70, 0, 0); } dialogContext.text = msg; OnOKClickHandler = okAction; OnCancelClickHandler = cancelAction; }
public void FadeIn(UIDialogType dialogType) { if (!fadeIn && !Visible) { Type = dialogType; vtForeground = new Vector2(400 - texForeground[Type].Width / 2, 200 - texForeground[Type].Height / 2); switch (Type) { case UIDialogType.Confirm: btnYes.Position = new Vector2(vtForeground.X + 24, vtForeground.Y + 330); btnNo.Position = new Vector2(vtForeground.X + 210, vtForeground.Y + 330); break; case UIDialogType.Message: btnOk.Position = new Vector2(vtForeground.X + 117, vtForeground.Y + 330); break; } ; fadeIn = Visible = true; } }
/// <summary> /// 打开对话框的同时显示提示信息,给按钮添加委托,需要弹出UI对话框时使用 /// </summary> /// <param name="msg"></param> /// <param name="okAction"></param> /// <param name="cancelAction"></param> protected void ShowDialog(string msg, UIDialogType type = UIDialogType.OK, Action okAction = null, Action cancelAction = null) { UIDialogController.Instance.Show(msg, type, okAction, cancelAction); }