void Awake()
        {
            ISN_RPScreenRecorder.DidChangeAvailability.AddSafeListener(this, () => {
                //Do something
            });

            ISN_RPScreenRecorder.DidStopRecording.AddSafeListener(this, OnRecordStopped);



            DateTime starDate             = DateTime.Now;
            ISN_UIDateTimePickerMode mode = ISN_UIDateTimePickerMode.DateAndTime;

            ISN_UIDateTimePicker.Show(mode, starDate, (DateTime date) => {
                Debug.Log("User picked date: " + date.ToLongDateString());
            });

            ISN_UIDateTimePicker.OnPickerDateChanged.AddListener((DateTime date) => {
                Debug.Log("User chnaged a date to: " + date.ToLongDateString());
            });


            ISN_UICalendar.PickDate((DateTime date) => {
                Debug.Log("User picked date: " + date.ToLongDateString());
            });
        }
        /// <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;
                }
            }
        }
Пример #3
0
        void OnGUI()
        {
            UpdateToStartPos();

            GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Popups", style);



            StartY += YLableStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Load Store"))
            {
                ISN_UIAlertController alert         = new ISN_UIAlertController("My Alert", "granted", ISN_UIAlertControllerStyle.Alert);
                ISN_UIAlertAction     defaultAction = new ISN_UIAlertAction("Ok", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                });

                defaultAction.SetImage(m_icon);

                alert.AddAction(defaultAction);
                alert.Present();


                SA_Coroutine.WaitForSeconds(3f, () => {
                    alert.Dismiss();
                });
            }



            StartX  = XStartPos;
            StartY += YButtonStep;

            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Perform Buy #1"))
            {
                ISN_UIAlertController alert         = new ISN_UIAlertController("My Alert", "declined", ISN_UIAlertControllerStyle.Alert);
                ISN_UIAlertAction     defaultAction = new ISN_UIAlertAction("Ok", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                });

                ISN_UIAlertAction defaultAction2 = new ISN_UIAlertAction("No", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                });

                defaultAction.Enabled  = true;
                defaultAction2.Enabled = false;


                ISN_UIAlertAction prefAction = new ISN_UIAlertAction("Hit me", ISN_UIAlertActionStyle.Default, () => {
                    //Do something
                    Debug.Log("Got it!!!!");
                });

                prefAction.MakePreffered();

                alert.AddAction(defaultAction);
                alert.AddAction(defaultAction2);
                alert.AddAction(prefAction);
                alert.Present();
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Perform Buy #2"))
            {
                ISN_Preloader.LockScreen();

                SA_Coroutine.WaitForSeconds(3f, () => {
                    ISN_Preloader.UnlockScreen();
                });
            }


            StartX  = XStartPos;
            StartY += YButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Calendar Picker"))
            {
                ISN_UICalendar.PickDate((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }


            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Date Time Picker"))
            {
                //20 days ago
                DateTime starDate = DateTime.Now;
                starDate = starDate.AddDays(-20);

                ISN_UIDateTimePicker picker = new ISN_UIDateTimePicker();
                picker.SetDate(starDate);

                picker.Show((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Date Picker"))
            {
                //20 days ago
                DateTime starDate = DateTime.Now;
                starDate = starDate.AddDays(-20);

                ISN_UIDateTimePicker picker = new ISN_UIDateTimePicker();
                picker.SetDate(starDate);
                picker.DatePickerMode = ISN_UIDateTimePickerMode.Date;

                picker.Show((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Time Picker"))
            {
                //20 hours ago
                DateTime starDate = DateTime.Now;
                starDate = starDate.AddHours(-20);

                ISN_UIDateTimePicker picker = new ISN_UIDateTimePicker();
                picker.SetDate(starDate);
                picker.DatePickerMode = ISN_UIDateTimePickerMode.Time;
                picker.MinuteInterval = 30;

                picker.Show((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }

            StartX += XButtonStep;
            if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Countdown Timer"))
            {
                ISN_UIDateTimePicker picker = new ISN_UIDateTimePicker();

                picker.DatePickerMode = ISN_UIDateTimePickerMode.CountdownTimer;
                picker.MinuteInterval = 10;

                //Set countdown start duration
                int      hours   = 5;
                int      minutes = 20;
                int      seconds = 0;
                TimeSpan span    = new TimeSpan(hours, minutes, seconds);
                picker.SetCountDownDuration(span);

                picker.Show((DateTime date) => {
                    ISN_Logger.Log("User picked date: " + date.ToLongDateString());
                });
            }
        }