示例#1
0
    public void PickTime()
    {
        Debug.Log("Pick native picker for repeat interval");

        if (Application.isEditor)
        {
            DateTime dateTime = _tempReminderData.fireDate.AddMinutes(10);
            _tempReminderData.fireDate = _tempReminderData.fireDate.Date + dateTime.TimeOfDay;
            UpdateView();
        }
        else
        {
            NativePicker.Instance.ShowTimePicker(_nativePopupRect, DateTime.Now,
                                                 val =>
            {
                DateTime dateTime          = NativePicker.ConvertToDateTime(val);
                _tempReminderData.fireDate = _tempReminderData.fireDate.Date + dateTime.TimeOfDay;
                UpdateView();
            },
                                                 () =>
            {
                // do nothing
            }
                                                 );
        }
    }
 public void OnDateTimePredefined(Object button)
 {
     NativePicker.Instance.ShowDateTimePicker(GetScreenRect(button as GameObject), NativePicker.DateTimeForDateTime(2012, 12, 23, 13, 45, 00), (long val) => {
         SelectedDateTimeString2 = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd H:mm");
     }, () => {
         SelectedDateTimeString2 = "canceled";
     });
 }
 public void OnDateTime(Object button)
 {
     NativePicker.Instance.ShowDateTimePicker(GetScreenRect(button as GameObject), (long val) => {
         SelectedDateTimeString1 = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd H:mm");
     }, () => {
         SelectedDateTimeString1 = "canceled";
     });
 }
 public void OnTimePredefined(Object button)
 {
     NativePicker.Instance.ShowTimePicker(GetScreenRect(button as GameObject), NativePicker.DateTimeForTime(14, 45, 0), (long val) => {
         SelectedTimeString2 = NativePicker.ConvertToDateTime(val).ToString("H:mm");
     }, () => {
         SelectedTimeString2 = "canceled";
     });
 }
示例#5
0
    void Awake()
    {
        _instance = this;
        if (isMobileRuntime == false)
        {
            //Debug.LogWarning("Due to platform specific NativePicker was designed to run only on iOS/Android device. Plugin function call has no effect on other platforms.");
            return;
        }
#if UNITY_ANDROID
        _pluginObject = new AndroidJavaObject("ua.org.jeff.unity.nativepicker.AndroidPlugin");
#endif
    }
示例#6
0
	void Awake() {		
		_instance = this;
		
		if (isMobileRuntime == false) {
			Debug.LogWarning("Due to platform specific NativePicker was designed to run only on iOS/Android device. Plugin function call has no effect on other platforms.");
			return;
		}
		
#if UNITY_ANDROID		
		_pluginObject = new AndroidJavaObject("ua.org.jeff.unity.nativepicker.AndroidPlugin");
#endif
	}
    public void showDatePicker(UnityEngine.Object button)
    {
        string UserId    = um.getCurrentUserId();
        string UserToken = um.getCurrentSessionToken();

        try{
            _textDatePredefined = GameObject.Find("textDatePredefined").GetComponent <Text> ();
        }catch (NullReferenceException ex) {}
        NativePicker.Instance.ShowDatePicker(GetScreenRect(button as GameObject), NativePicker.DateTimeForDate(2012, 12, 23), (long val) => {
            SelectedDateString2 = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd");
            ////Debug.Log("SelectedDateString2: "+SelectedDateString2);
        }, () => {
            //SelectedDateString2 = "canceled";
            SelectedDateString2 = DateTime.Now.ToString("yyyy-MM-dd");
            try{
                //_textDatePredefined.text=SelectedDateString2;
            }catch (NullReferenceException ex) {}
        });
    }
        /// <summary>
        /// Births the set.
        /// </summary>
        /// <returns>The set.</returns>
        public void BirthSet()
        {
            System.DateTime defaultSetDate = GetDateTimeByAge(18);

            int y = int.Parse(defaultSetDate.Year.ToString());
            int m = int.Parse(defaultSetDate.Month.ToString());
            int d = int.Parse(defaultSetDate.Day.ToString());

            NativePicker.Instance.ShowDatePicker(toScreenRect(_drawRect), NativePicker.DateTimeForDate(y, m, d), (long val) =>
            {
                _birthdayObjNative.transform.GetChild(0).GetComponent <Text>().text = "";
                _userData.birth_date = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd");
                _birthdayObjNative.transform.GetChild(1).GetComponent <Text>().text = NativePicker.ConvertToDateTime(val).ToString("yyyy年MM月dd日");
            }, () => {
                _birthdayObjNative.transform.GetChild(0).GetComponent <Text>().text = "生年月日を選択してください";
                _birthdayObjNative.transform.GetChild(1).GetComponent <Text>().text = "";
            });
            return;
        }
    //理想の睡眠時間の終了時間を設定します
    public void OnIdealSleeptimeendButtonTap(Object button)
    {
        var initDate = UserDataManager.Setting.Profile.GetIdealSleepEndTime();

        NativePicker.Instance.ShowTimePicker(GetScreenRect(button as GameObject), NativePicker.DateTimeForTime(initDate.Hour, initDate.Minute, 0), (long val) => {
            //時刻が変更された
            //表示を更新する
            var date = NativePicker.ConvertToDateTime(val);
            string dateTimeString      = date.Hour.ToString("00") + ":" + date.Minute.ToString("00");
            idealSleepTimeEndText.text = dateTimeString;
            //日付を保存する
            UserDataManager.Setting.Profile.SaveIdealSleepEndTime(date);
            OnChangeSetting();
        }, () => {
            //時刻の変更がキャンセルされた
            //保存した日付をもとに戻す
            UserDataManager.Setting.Profile.SaveIdealSleepEndTime(initDate);
            OnChangeSetting();
        });
    }
    //生年月日のボタンが押されたときに日付ピッカーを表示する
    public void OnBirthDayButtonTap(Object button)
    {
        DateTime initDate = UserDataManager.Setting.Profile.GetBirthDay();

        NativePicker.Instance.ShowDatePicker(GetScreenRect(button as GameObject), initDate, (long val) => {
            //日付が変更された
            var date = NativePicker.ConvertToDateTime(val);
            //表示を更新する
            string dateTimeString = date.Year.ToString() + "/" + date.Month.ToString() + "/" + date.Day.ToString();
            birthDayText.text     = dateTimeString;
            //日付を生年月日として保存する
            UserDataManager.Setting.Profile.SaveBirthDay(date);
            OnChangeSetting();
        }, () => {
            //日付の変更がキャンセルされた
            //変更を元に戻す
            UserDataManager.Setting.Profile.SaveBirthDay(initDate);
            OnChangeSetting();
        });
    }
示例#11
0
 public void showExpPicker(UnityEngine.Object button)
 {
     if (Age_Containter.GetComponent <Animator>().GetBool("young") == true)
     {
         Age_Containter.GetComponent <Animator>().SetBool("young", false);
     }
     Birthdate = GameObject.Find("AgeInfoPers").GetComponent <Text>();
     NativePicker.Instance.ShowDatePicker(GetScreenRect(button as GameObject), NativePicker.DateTimeForDate(2012, 12, 23), (long val) =>
     {
         SelectedDateString2 = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd");
         Birthdate.text      = SelectedDateString2;
         string[] attrib     = { "birthdate" };
         string[] values     = { Birthdate.text };
         string[] date       = Birthdate.text.Split(new char[] { '-' }, 3);
         string Years        = date[0];
         string Days         = date[2];
         string Months       = date[1];
         Debug.Log("Years: " + Years);
         if (DateTime.UtcNow.Year - int.Parse(Years) >= 18)
         {
             UnityThreadHelper.CreateThread(async() =>
             {
                 if (await updateStripeAccount("birthdate", Birthdate.text))
                 {
                     updateUser(attrib, values);
                 }
             });
         }
         else
         {
             // Age <18 : Show Error Text
             Age_Containter.GetComponent <Animator>().SetBool("young", true);
         }
     }, () =>
     {
         //SelectedDateString2 = DateTime.Now.ToString("yyyy-MM-dd");
     });
 }
        /// <summary>
        /// Births the set.
        /// </summary>
        /// <returns>The set.</returns>
        public void BirthSet()
        {
            int y = 0;
            int m = 0;
            int d = 0;

            if (string.IsNullOrEmpty(MypageEventManager.Instance._birthDate) == true)
            {
                System.DateTime defaultSetDate = GetDateTimeByAge(18);

                y = int.Parse(defaultSetDate.Year.ToString());
                m = int.Parse(defaultSetDate.Month.ToString());
                d = int.Parse(defaultSetDate.Day.ToString());
            }
            else
            {
                string[] bdArray = MypageEventManager.Instance._birthDate.Split('-');
                y = int.Parse(bdArray[0]);
                m = int.Parse(bdArray[1]);
                d = int.Parse(bdArray[2]);
            }

            NativePicker.Instance.ShowDatePicker(toScreenRect(_drawRect), NativePicker.DateTimeForDate(y, m, d), (long val) =>
            {
                //プロフィールの変更がある事を通知する用
                _isProfileChangeState = true;

                _birthdayObjNative.transform.GetChild(0).GetComponent <Text>().text = "";
                MypageEventManager.Instance._birthDate = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd");
                _birthdayObjNative.transform.GetChild(1).GetComponent <Text>().text = NativePicker.ConvertToDateTime(val).ToString("yyyy年MM月dd日");
            }, () => {
                _birthdayObjNative.transform.GetChild(0).GetComponent <Text>().text = "生年月日を選択してください";
                _birthdayObjNative.transform.GetChild(1).GetComponent <Text>().text = "";
            });
            return;
        }
 public void showExpPicker(UnityEngine.Object button)
 {
     _textDatePredefined = GameObject.Find("AgeInfoPers").GetComponent <Text> ();
     if (PersonelInfoController.getInstance().Age_Containter.GetComponent <Animator>().GetBool("young") == true)
     {
         PersonelInfoController.getInstance().Age_Containter.GetComponent <Animator>().SetBool("young", false);
     }
     NativePicker.Instance.ShowDatePicker(GetScreenRect(button as GameObject), NativePicker.DateTimeForDate(2012, 12, 23), async(long val) => {
         SelectedDateString2      = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd");
         _textDatePredefined.text = SelectedDateString2;
         Debug.Log("showExpPicker: birthdate: " + _textDatePredefined.text);
         string[] attrib = { "birthdate" };
         string[] values = { _textDatePredefined.text };
         string userId   = um.getCurrentUserId();
         string token    = um.getCurrentSessionToken();
         string[] date   = _textDatePredefined.text.Split(new char[] { '-' }, 3);
         string Years    = date[0];
         string Days     = date[2];
         string Months   = date[1];
         Debug.Log("Years: " + Years);
         if (DateTime.UtcNow.Year - int.Parse(Years) >= 18)
         {
             if (await PersonelInfoController.getInstance().updateStripeAccount("birthdate", _textDatePredefined.text))
             {
                 PersonelInfoController.getInstance().updateUser(attrib, values);
             }
         }
         else
         {
             // Age <18 : Show Error Text
             PersonelInfoController.getInstance().Age_Containter.GetComponent <Animator>().SetBool("young", true);
         }
     }, () => {
         //SelectedDateString2 = "canceled";
     });
 }
示例#14
0
        void OnGUI()
        {
            float width    = Screen.width / 2;
            float height   = Screen.width / 14;
            Rect  drawRect = new Rect((Screen.width - width) / 2, height, width, height);

            // show date picker with current date selected
            if (GUI.Button(drawRect, "Date picker"))
            {
                NativePicker.Instance.ShowDatePicker(toScreenRect(drawRect), (long val) => {
                    _selectedDateString1 = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd");
                }, () => {
                    _selectedDateString1 = "canceled";
                });
            }

            if (NativePicker.iPhonePlatform)
            {
                // hide picker button
                // due to iPhone design guidelines picker should appear at bottom of the screen (like keyboard)
                // and should be hidden manually
                Rect closeButtonRect = new Rect(drawRect);
                closeButtonRect.x    += closeButtonRect.width;
                closeButtonRect.width = Screen.width / 4;
                if (GUI.Button(closeButtonRect, "Hide picker"))
                {
                    NativePicker.Instance.HidePicker();
                }
            }

            // display selected date
            drawRect.y += height;
            GUI.Label(drawRect, "Selected date: " + _selectedDateString1, _labelStyle);


            // show date picker with custom date selected
            drawRect.y += height;
            if (GUI.Button(drawRect, "Date picker: 2012-12-23"))
            {
                NativePicker.Instance.ShowDatePicker(toScreenRect(drawRect), NativePicker.DateTimeForDate(2012, 12, 23), (long val) => {
                    _selectedDateString2 = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd");
                }, () => {
                    _selectedDateString2 = "canceled";
                });
            }

            // display selected date
            drawRect.y += height;
            GUI.Label(drawRect, "Selected date: " + _selectedDateString2, _labelStyle);


            // show time picker with current time selected
            drawRect.y += height;
            if (GUI.Button(drawRect, "Time picker"))
            {
                NativePicker.Instance.ShowTimePicker(toScreenRect(drawRect), (long val) => {
                    _selectedTimeString1 = NativePicker.ConvertToDateTime(val).ToString("H:mm");
                }, () => {
                    _selectedTimeString1 = "canceled";
                });
            }

            // display selected time
            drawRect.y += height;
            GUI.Label(drawRect, "Selected time: " + _selectedTimeString1, _labelStyle);


            // show time picker with custom time selected
            drawRect.y += height;
            if (GUI.Button(drawRect, "Time picker: 14:45"))
            {
                NativePicker.Instance.ShowTimePicker(toScreenRect(drawRect), NativePicker.DateTimeForTime(14, 45, 0), (long val) => {
                    _selectedTimeString2 = NativePicker.ConvertToDateTime(val).ToString("H:mm");
                }, () => {
                    _selectedTimeString2 = "canceled";
                });
            }

            // display selected time
            drawRect.y += height;
            GUI.Label(drawRect, "Selected time: " + _selectedTimeString2, _labelStyle);


            // show picker with custom item list
            drawRect.y += height;
            if (GUI.Button(drawRect, "Custom picker"))
            {
                NativePicker.Instance.ShowCustomPicker(toScreenRect(drawRect), _itemList, (long val) => {
                    _selectedItemString1 = _itemList[val];
                }, () => {
                    _selectedItemString1 = "canceled";
                });
            }

            // display selected item
            drawRect.y += height;
            GUI.Label(drawRect, "Selected item: " + _selectedItemString1, _labelStyle);


            // show show custom picker with selected item
            drawRect.y += height;
            if (GUI.Button(drawRect, "Custom picker: item 2"))
            {
                NativePicker.Instance.ShowCustomPicker(toScreenRect(drawRect), _itemList, 1, (long val) => {
                    _selectedItemString2 = _itemList[val];
                }, () => {
                    _selectedItemString2 = "canceled";
                });
            }

            // display selected item
            drawRect.y += height;
            GUI.Label(drawRect, "Selected item: " + _selectedItemString2, _labelStyle);

#if UNITY_IPHONE
            // show date and time picker with current date selected
            drawRect.y += height;
            if (GUI.Button(drawRect, "Date and time picker"))
            {
                NativePicker.Instance.ShowDateTimePicker(toScreenRect(drawRect), (long val) => {
                    _selectedDateTimeString1 = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd H:mm");
                }, () => {
                    _selectedDateTimeString1 = "canceled";
                });
            }

            // display selected date
            drawRect.y += height;
            GUI.Label(drawRect, "Selected date: " + _selectedDateTimeString1, _labelStyle);


            // show date and time picker with custom date selected
            drawRect.y += height;
            if (GUI.Button(drawRect, "Date and time picker: 2012-12-23 13:45"))
            {
                NativePicker.Instance.ShowDateTimePicker(toScreenRect(drawRect), NativePicker.DateTimeForDateTime(2012, 12, 23, 13, 45, 00), (long val) => {
                    _selectedDateTimeString2 = NativePicker.ConvertToDateTime(val).ToString("yyyy-MM-dd H:mm");
                }, () => {
                    _selectedDateTimeString2 = "canceled";
                });
            }

            // display selected date
            drawRect.y += height;
            GUI.Label(drawRect, "Selected date: " + _selectedDateTimeString2, _labelStyle);
#endif
        }