Beispiel #1
0
 /// <summary>
 /// Create Wheel UIPickerView.
 /// It will create UIPickerView with cancel and done buttons.
 /// </summary>
 public void ShowUIWheelPicker(ISN_UIWheelPickerController controller, Action <ISN_UIWheelPickerResult> callback)
 {
     #if UNITY_IPHONE
     var data = JsonUtility.ToJson(controller);
     _ISN_UIWheelPicker(ISN_MonoPCallback.ActionToIntPtr(callback), data);
     #endif
 }
        /// <summary>
        /// Start of the dialog display in on screen.
        /// </summary>
        public void Show(Action <UM_WheelPickerResult> callback)
        {
            if (Application.isEditor)
            {
#if UNITY_EDITOR
                UnityEditor.EditorUtility.DisplayDialog(
                    "Not supported",
                    "The wheel picker view emulation is not supported inside the Editor.\n" +
                    "First value of the list will be returned as dialog result.",
                    "Okay");
                UM_WheelPickerResult result;
                if (m_Values != null && m_Values.Count > 0)
                {
                    result = new UM_WheelPickerResult(m_Values[0]);
                }
                else
                {
                    result = new UM_WheelPickerResult("Null");
                }
                callback.Invoke(result);
#endif
            }
            else
            {
                switch (Application.platform)
                {
                case RuntimePlatform.Android:
                    AN_WheelPickerDialog picker = new AN_WheelPickerDialog(m_Values);
                    picker.Show((pickerResult) =>
                    {
                        UM_WheelPickerResult result;
                        if (pickerResult.IsSucceeded)
                        {
                            var pickerValue = pickerResult.Value;
                            result          = new UM_WheelPickerResult(pickerValue);
                        }
                        else
                        {
                            result = new UM_WheelPickerResult(pickerResult.Error);
                        }
                        callback.Invoke(result);
                    });
                    break;

                case RuntimePlatform.IPhonePlayer:
                    ISN_UIWheelPickerController pickerController = new ISN_UIWheelPickerController(m_Values);
                    pickerController.Show((pickerResult) =>
                    {
                        UM_WheelPickerResult result;
                        if (pickerResult.IsSucceeded)
                        {
                            var pickerValue = pickerResult.Value;
                            result          = new UM_WheelPickerResult(pickerValue);
                        }
                        else
                        {
                            result = new UM_WheelPickerResult(pickerResult.Error);
                        }
                        callback.Invoke(result);
                    });
                    break;
                }
            }
        }