public void DisplayAlert(string title, string message, string postiveButtonText, string neutralButtonText, string negativeButtonText,
                             Action positiveCallback, Action neutralCallback, Action negativeCallback, Action dismissCallback = null)
    {
        if (IsPreloading)
        {
            Dismiss();
        }

        AndroidAlertDialog dialog = new AndroidAlertDialog(title, message);

        dialog.AddAction(AlertActionType.Positive, postiveButtonText, () => { if (positiveCallback != null)
                                                                              {
                                                                                  positiveCallback();
                                                                              }
                         });
        dialog.AddAction(AlertActionType.Neutral, neutralButtonText, () => { if (neutralCallback != null)
                                                                             {
                                                                                 neutralCallback();
                                                                             }
                         });
        dialog.AddAction(AlertActionType.Negative, negativeButtonText, () => { if (negativeCallback != null)
                                                                               {
                                                                                   negativeCallback();
                                                                               }
                         });
        dialog.AddDismissListener(() => { if (dismissCallback != null)
                                          {
                                              dismissCallback();
                                          }
                                  });
        dialog.Show();
    }
Exemplo n.º 2
0
        private void ShowAndroidUpdateDialog(string appUpdateUrl)
        {
            CommonLog.Log(MAuthor.ZX, "Open Android Update Dialog");
            AndroidJavaClass  unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject activity    = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");

            AndroidAlertDialog alertDialog = new AndroidAlertDialog(activity);

            alertDialog.SetTitle("游戏版本检测");
            alertDialog.SetMessage("检测到有新的游戏版本,是否更新?");
            alertDialog.SetPositiveButton("是", new AlertDialogClickListener((dialog, which) =>
            {
                //跳转App更新界面
                Application.OpenURL(appUpdateUrl);
                //强制退出
                Application.Quit();
            }));
            alertDialog.SetNegativeButton("否", new AlertDialogClickListener((dialog, which) =>
            {
                //强制退出
                Application.Quit();
            }));
            alertDialog.Create();
            alertDialog.Show();
        }
Exemplo n.º 3
0
    /// <summary>
    /// 显示Android升级弹窗
    /// </summary>
    private void ShowAndroidUpdateDialog()
    {
        CommonLog.Log(MAuthor.ZX, "Open Android Update Dialog");
        AndroidJavaClass  unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject activity    = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");

        AndroidAlertDialog alertDialog = new AndroidAlertDialog(activity);

        alertDialog.SetTitle("游戏版本检测");
        alertDialog.SetMessage("检测到有新的游戏版本,是否更新?");
        alertDialog.SetPositiveButton("是", new AlertDialogClickListener(OnConfirm));
        alertDialog.SetNegativeButton("否", new AlertDialogClickListener(OnCancel));
        alertDialog.Create();
        alertDialog.Show();
    }
    public void DisplayAlert(string title, string message, string buttonText, Action callback, Action dismissCallback = null)
    {
        if (IsPreloading)
        {
            Dismiss();
        }

        AndroidAlertDialog dialog = new AndroidAlertDialog(title, message);

        dialog.AddAction(AlertActionType.Positive, buttonText, () => { if (callback != null)
                                                                       {
                                                                           callback();
                                                                       }
                         });
        dialog.AddDismissListener(() => { if (dismissCallback != null)
                                          {
                                              dismissCallback();
                                          }
                                  });
        dialog.Show();
    }