/// <summary> /// Start the dialog and display it on screen. /// </summary> public void Show(Action <UN_DatePickerResult> callback) { if (Application.isEditor) { #if UNITY_EDITOR UnityEditor.EditorUtility.DisplayDialog( "Not Supported", "The date picker view emulation is not supported inside the Editor. " + "The DateTime.Now value will be returned as dialog result.", "Okay"); var result = new UN_DatePickerResult(DateTime.Now); callback.Invoke(result); #endif } else { switch (Application.platform) { case RuntimePlatform.Android: var date = DateTime.Now; int year = m_year; int month = date.Month - 1; //Compatibility with Android Calendar.. int day = date.Day; AN_DatePickerDialog picker = new AN_DatePickerDialog(year, month, day); picker.Show((pickerResult) => { UN_DatePickerResult result; if (pickerResult.IsSucceeded) { var pickedDate = new DateTime(pickerResult.Year, pickerResult.Month + 1, pickerResult.Day); result = new UN_DatePickerResult(pickedDate); } else { result = new UN_DatePickerResult(pickerResult.Error); } callback.Invoke(result); }); break; case RuntimePlatform.IPhonePlayer: ISN_UICalendar.PickDate((pickedDate) => { var result = new UN_DatePickerResult(pickedDate); callback.Invoke(result); }, m_year); break; } } }
void Start() { m_progressButton.onClick.AddListener(() => { //Show the preloader AN_Preloader.LockScreen("Please Wait..."); //and hide it in 2 sec SA_Coroutine.WaitForSeconds(2f, () => { AN_Preloader.UnlockScreen(); }); }); m_messageButton.onClick.AddListener(() => { var message = new AN_AlertDialog(AN_DialogTheme.Material); message.Title = "Message"; message.Message = "Some message text"; message.SetPositiveButton("Okay", () => { AN_Logger.Log("message: ok button was clicked"); }); message.Show(); }); m_dialogButton.onClick.AddListener(() => { var dialog = new AN_AlertDialog(AN_DialogTheme.Light); dialog.Title = "Dialog"; dialog.Message = "Some dialog text"; dialog.SetPositiveButton("Yes", () => { AN_Logger.Log("dialog: Yes button was clicked"); }); dialog.SetNegativeButton("No", () => { AN_Logger.Log("dialog: No button was clicked"); }); dialog.Show(); }); m_rateButton.onClick.AddListener(() => { string appName = Application.productName; string appIdentifier = Application.identifier; var dialog = new AN_AlertDialog(AN_DialogTheme.Default); dialog.Title = string.Format("Rate {0}!", appName); dialog.Message = string.Format("If you enjoy using {0}, please take a moment to rate it.Thanks for your support!", appName); dialog.SetPositiveButton("Rate", () => { AN_Logger.Log("dialog: Rate button was clicked"); //This code will take user to your app Play Market page System.Uri uri = new System.Uri("market://details?id=" + appIdentifier); AN_Intent viewIntent = new AN_Intent(AN_Intent.ACTION_VIEW, uri); AN_MainActivity.Instance.StartActivity(viewIntent); }); dialog.SetNegativeButton("No, thanks", () => { AN_Logger.Log("dialog: No, thanks button was clicked"); }); dialog.SetNeutralButton("Remind me later", () => { AN_Logger.Log("dialog: Remind me later button was clicked"); }); dialog.Show(); }); m_calendarButton.onClick.AddListener(() => { var date = DateTime.Now; int year = date.Year; int month = date.Month - 1; //Compatibility with Android Calendar.. int day = date.Day; AN_DatePickerDialog picker = new AN_DatePickerDialog(year, month, day); picker.Show((result) => { if (result.IsSucceeded) { Debug.Log("date picked result.Year: " + result.Year); //Same Android Calendar Compatibility Debug.Log("date picked result.Month: " + result.Month + 1); Debug.Log("date picked result.Day: " + result.Day); } else { Debug.Log("Failed to pick a date: " + result.Error.FullMessage); } }); }); }