Exemplo n.º 1
0
        public static void Open(UIElement focused_)
        {
            string text = "";
            TouchScreenKeyboardType keyboardType = TouchScreenKeyboardType.Default;
            bool multiline      = false;
            bool secure         = false;
            int  characterLimit = 0;

            if (focused_ is FrameworkElement)
            {
                switch (((FrameworkElement)focused_).InputScope)
                {
                case InputScope.Url:
                    keyboardType = TouchScreenKeyboardType.URL;
                    break;

                case InputScope.Digits:
                case InputScope.Number:
                case InputScope.NumberFullWidth:
                    keyboardType = TouchScreenKeyboardType.NumbersAndPunctuation;
                    break;

                case InputScope.TelephoneNumber:
                case InputScope.TelephoneLocalNumber:
                    keyboardType = TouchScreenKeyboardType.PhonePad;
                    break;

                case InputScope.AlphanumericFullWidth:
                case InputScope.AlphanumericHalfWidth:
                    keyboardType = TouchScreenKeyboardType.NamePhonePad;
                    break;

                case InputScope.EmailSmtpAddress:
                    keyboardType = TouchScreenKeyboardType.EmailAddress;
                    break;

                case InputScope.RegularExpression:
                    keyboardType = TouchScreenKeyboardType.Search;
                    break;

                default:
                    keyboardType = TouchScreenKeyboardType.Default;
                    break;
                }
            }

            TextBox     textBox     = focused_ as TextBox;
            PasswordBox passwordBox = focused_ as PasswordBox;

            if (textBox != null)
            {
                text           = textBox.Text;
                multiline      = textBox.TextWrapping == TextWrapping.Wrap && textBox.AcceptsReturn;
                characterLimit = textBox.MaxLength;
                textBox.HideCaret();
            }
            else if (passwordBox != null)
            {
                text   = passwordBox.Password;
                secure = true;
                passwordBox.HideCaret();
            }

#if UNITY_2018_1_OR_NEWER
            keyboard = TouchScreenKeyboard.Open(text, keyboardType, true, multiline, secure, false, "", characterLimit);
#else
            keyboard = TouchScreenKeyboard.Open(text, keyboardType, true, multiline, secure, false, "");
#endif
            focused    = focused_;
            undoString = text;
        }
Exemplo n.º 2
0
 // Opens native keyboard
 void OnGUI()
 {
     TouchScreenKeyboard.hideInput = true;
     stringToEdit = GUI.TextField(new Rect(10, 10, 200, 30), stringToEdit, 30);
     keyboard     = TouchScreenKeyboard.Open(stringToEdit, keyboardType, false, false);
 }
Exemplo n.º 3
0
    /// <summary>
    /// Update the text based on input.
    /// </summary>

    void Update()
    {
#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            return;
        }
#endif
        if (isSelected)
        {
            if (mDoInit)
            {
                Init();
            }

            // Unity has issues bringing up the keyboard properly if it's in "hideInput" mode and you happen
            // to select one input in the same Update as de-selecting another.
            if (mSelectMe != -1 && mSelectMe != Time.frameCount)
            {
                mSelectMe = -1;

                label.color = activeTextColor;
#if MOBILE
                if (Application.platform == RuntimePlatform.IPhonePlayer ||
                    Application.platform == RuntimePlatform.Android ||
                    Application.platform == RuntimePlatform.WP8Player
#if UNITY_4_0 || UNITY_4_2 || UNITY_4_3
                    || Application.platform == RuntimePlatform.BB10Player
#else
                    || Application.platform == RuntimePlatform.BlackBerryPlayer
#endif
                    )
                {
                    string val;
                    TouchScreenKeyboardType kt;

                    if (keyboardType == KeyboardType.HiddenInput)
                    {
                        TouchScreenKeyboard.hideInput = true;
                        kt  = TouchScreenKeyboardType.Default;
                        val = "|";
                    }
                    else if (inputType == InputType.Password)
                    {
                        TouchScreenKeyboard.hideInput = false;
                        kt  = TouchScreenKeyboardType.Default;
                        val = mValue;
                    }
                    else
                    {
                        TouchScreenKeyboard.hideInput = false;
                        kt  = (TouchScreenKeyboardType)((int)keyboardType);
                        val = mValue;
                    }

                    mKeyboard = (inputType == InputType.Password) ?
                                TouchScreenKeyboard.Open(val, kt, false, false, true) :
                                TouchScreenKeyboard.Open(val, kt, inputType == InputType.AutoCorrect, label.multiLine, false, false, defaultText);
                }
                else
#endif
                {
                    Vector2 pos = (UICamera.current != null && UICamera.current.cachedCamera != null) ?
                                  UICamera.current.cachedCamera.WorldToScreenPoint(label.worldCorners[0]) :
                                  label.worldCorners[0];
                    pos.y = Screen.height - pos.y;
                    Input.imeCompositionMode   = IMECompositionMode.On;
                    Input.compositionCursorPos = pos;

                    mSelectionStart = 0;
                    mSelectionEnd   = string.IsNullOrEmpty(mValue) ? 0 : mValue.Length;
                    mDrawStart      = 0;
                }
                UpdateLabel();
            }
#if MOBILE
            if (mKeyboard != null)
            {
                string text = mKeyboard.text;

                if (TouchScreenKeyboard.hideInput)
                {
                    if (text != "|")
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            //Insert(text.Substring(1));
                        }
                        else
                        {
                            DoBackspace();
                        }

                        mKeyboard.text = "|";
                    }
                }
                else if (mCached != text)
                {
                    mCached = text;
                    value   = text;
                }

                if (mKeyboard.done || !mKeyboard.active)
                {
                    // if (!mKeyboard.active)
                    //AndroidPluginManager.showToast("키보드 닫힘 :" + mKeyboard.active, true);
                    //if (mKeyboard.wasCanceled)
                    //AndroidPluginManager.showToast("캔슬키 눌림 : " + mKeyboard.wasCanceled, true);
                    //if (mKeyboard.done)
                    //AndroidPluginManager.showToast("확인키 눌림 : " + mKeyboard.done, true);
                    if (mKeyboard.done && !mKeyboard.wasCanceled)
                    {
                        Submit();
                    }
                    else
                    {
                        ExecuteOnRelease();
                    }
                    mKeyboard  = null;
                    isSelected = false;
                    mCached    = "";
                }
            }
            else
#endif
            {
                if (selectOnTab != null && Input.GetKeyDown(KeyCode.Tab))
                {
                    UICamera.selectedObject = selectOnTab;
                    return;
                }

                string ime = Input.compositionString;

                // There seems to be an inconsistency between IME on Windows, and IME on OSX.
                // On Windows, Input.inputString is always empty while IME is active. On the OSX it is not.
                //if (string.IsNullOrEmpty(ime) && !string.IsNullOrEmpty(Input.inputString))
                if (!string.IsNullOrEmpty(Input.inputString))
                {
                    // Process input ignoring non-printable characters as they are not consistent.
                    // Windows has them, OSX may not. They get handled inside OnGUI() instead.
                    string s = Input.inputString;

                    for (int i = 0; i < s.Length; ++i)
                    {
                        char ch = s[i];
                        if (ch < ' ')
                        {
                            continue;
                        }

                        // OSX inserts these characters for arrow keys
                        if (ch == '\uF700')
                        {
                            continue;
                        }
                        if (ch == '\uF701')
                        {
                            continue;
                        }
                        if (ch == '\uF702')
                        {
                            continue;
                        }
                        if (ch == '\uF703')
                        {
                            continue;
                        }

                        Insert(ch.ToString());
                    }
                }

                // Append IME composition
                if (mLastIME != ime)
                {
                    mSelectionEnd = string.IsNullOrEmpty(ime) ? mSelectionStart : mValue.Length + ime.Length;
                    mLastIME      = ime;
                    UpdateLabel();
                    ExecuteOnChange();
                }
            }

            // Blink the caret
            if (mCaret != null && mNextBlink < RealTime.time)
            {
                mNextBlink     = RealTime.time + 0.5f;
                mCaret.enabled = !mCaret.enabled;
            }

            // If the label's final alpha changes, we need to update the drawn geometry,
            // or the highlight widgets (which have their geometry set manually) won't update.
            if (isSelected && mLastAlpha != label.finalAlpha)
            {
                UpdateLabel();
            }
        }
    }
Exemplo n.º 4
0
 public void abreTeclado()
 {
     TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, true);
 }
Exemplo n.º 5
0
 private void Start()
 {
     applyButton.GetComponent <Button>().interactable = false;
     TouchScreenKeyboard.Open(inputField.text);
 }
Exemplo n.º 6
0
    //[SerializeField] public TCPClient client;

    public void OnKeyboardCalled()
    {
        keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, false, false);
    }
 public static void SaveData()
 {
     keyboard      = TouchScreenKeyboard.Open(keyboardString, TouchScreenKeyboardType.Default, false);
     startedSaving = true;
 }
Exemplo n.º 8
0
 // キーボードを出す
 public void OpenKeyboard()
 {
     keyboard   = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
     isKeyboard = true;
 }
Exemplo n.º 9
0
 protected virtual void Update()
 {
     if (!this.isSelected || this.mSelectTime == Time.frameCount)
     {
         return;
     }
     if (this.mDoInit)
     {
         this.Init();
     }
     if (UIInput.mWaitForKeyboard)
     {
         if (UIInput.mKeyboard != null && !UIInput.mKeyboard.active)
         {
             return;
         }
         UIInput.mWaitForKeyboard = false;
     }
     if (this.mSelectMe != -1 && this.mSelectMe != Time.frameCount)
     {
         this.mSelectMe       = -1;
         this.mSelectionEnd   = ((!string.IsNullOrEmpty(this.mValue)) ? this.mValue.Length : 0);
         UIInput.mDrawStart   = 0;
         this.mSelectionStart = ((!this.selectAllTextOnFocus) ? this.mSelectionEnd : 0);
         this.label.color     = this.activeTextColor;
         RuntimePlatform platform = Application.platform;
         if (platform == RuntimePlatform.IPhonePlayer || platform == RuntimePlatform.Android || platform == RuntimePlatform.WP8Player || platform == RuntimePlatform.BlackBerryPlayer || platform == RuntimePlatform.MetroPlayerARM || platform == RuntimePlatform.MetroPlayerX64 || platform == RuntimePlatform.MetroPlayerX86)
         {
             TouchScreenKeyboardType touchScreenKeyboardType;
             string text;
             if (this.inputShouldBeHidden)
             {
                 TouchScreenKeyboard.hideInput = true;
                 touchScreenKeyboardType       = (TouchScreenKeyboardType)this.keyboardType;
                 text = "|";
             }
             else
             {
                 if (this.inputType == UIInput.InputType.Password)
                 {
                     TouchScreenKeyboard.hideInput = false;
                     touchScreenKeyboardType       = (TouchScreenKeyboardType)this.keyboardType;
                     text = this.mValue;
                     this.mSelectionStart = this.mSelectionEnd;
                 }
                 else
                 {
                     TouchScreenKeyboard.hideInput = false;
                     touchScreenKeyboardType       = (TouchScreenKeyboardType)this.keyboardType;
                     text = this.mValue;
                     this.mSelectionStart = this.mSelectionEnd;
                 }
             }
             UIInput.mWaitForKeyboard = true;
             UIInput.mKeyboard        = ((this.inputType != UIInput.InputType.Password) ? TouchScreenKeyboard.Open(text, touchScreenKeyboardType, !this.inputShouldBeHidden && this.inputType == UIInput.InputType.AutoCorrect, this.label.multiLine && !this.hideInput, false, false, this.defaultText) : TouchScreenKeyboard.Open(text, touchScreenKeyboardType, false, false, true));
         }
         else
         {
             Vector2 compositionCursorPos = (!(UICamera.current != null) || !(UICamera.current.cachedCamera != null)) ? this.label.worldCorners[0] : UICamera.current.cachedCamera.WorldToScreenPoint(this.label.worldCorners[0]);
             compositionCursorPos.y     = (float)Screen.height - compositionCursorPos.y;
             Input.imeCompositionMode   = IMECompositionMode.On;
             Input.compositionCursorPos = compositionCursorPos;
         }
         this.UpdateLabel();
         if (string.IsNullOrEmpty(Input.inputString))
         {
             return;
         }
     }
     if (UIInput.mKeyboard != null)
     {
         string text2 = (!UIInput.mKeyboard.done && UIInput.mKeyboard.active) ? UIInput.mKeyboard.text : this.mCached;
         if (this.inputShouldBeHidden)
         {
             if (text2 != "|")
             {
                 if (!string.IsNullOrEmpty(text2))
                 {
                     this.Insert(text2.Substring(1));
                 }
                 else
                 {
                     if (!UIInput.mKeyboard.done && UIInput.mKeyboard.active)
                     {
                         this.DoBackspace();
                     }
                 }
                 UIInput.mKeyboard.text = "|";
             }
         }
         else
         {
             if (this.mCached != text2)
             {
                 this.mCached = text2;
                 if (!UIInput.mKeyboard.done && UIInput.mKeyboard.active)
                 {
                     this.value = text2;
                 }
             }
         }
         if (UIInput.mKeyboard.done || !UIInput.mKeyboard.active)
         {
             if (!UIInput.mKeyboard.wasCanceled)
             {
                 this.Submit();
             }
             UIInput.mKeyboard = null;
             this.isSelected   = false;
             this.mCached      = string.Empty;
         }
     }
     else
     {
         string compositionString = Input.compositionString;
         if (string.IsNullOrEmpty(compositionString) && !string.IsNullOrEmpty(Input.inputString))
         {
             string inputString = Input.inputString;
             for (int i = 0; i < inputString.Length; i++)
             {
                 char c = inputString[i];
                 if (c >= ' ')
                 {
                     if (c != '')
                     {
                         if (c != '')
                         {
                             if (c != '')
                             {
                                 if (c != '')
                                 {
                                     this.Insert(c.ToString());
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (UIInput.mLastIME != compositionString)
         {
             this.mSelectionEnd = ((!string.IsNullOrEmpty(compositionString)) ? (this.mValue.Length + compositionString.Length) : this.mSelectionStart);
             UIInput.mLastIME   = compositionString;
             this.UpdateLabel();
             this.ExecuteOnChange();
         }
     }
     if (this.mCaret != null && this.mNextBlink < RealTime.time)
     {
         this.mNextBlink     = RealTime.time + 0.5f;
         this.mCaret.enabled = !this.mCaret.enabled;
     }
     if (this.isSelected && this.mLastAlpha != this.label.finalAlpha)
     {
         this.UpdateLabel();
     }
     if (this.mCam == null)
     {
         this.mCam = UICamera.FindCameraForLayer(base.gameObject.layer);
     }
     if (this.mCam != null)
     {
         bool flag = false;
         if (this.label.multiLine)
         {
             bool flag2 = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
             if (this.onReturnKey == UIInput.OnReturnKey.Submit)
             {
                 flag = flag2;
             }
             else
             {
                 flag = !flag2;
             }
         }
         if (UICamera.GetKeyDown(this.mCam.submitKey0) || (this.mCam.submitKey0 == KeyCode.Return && UICamera.GetKeyDown(KeyCode.KeypadEnter)))
         {
             if (flag)
             {
                 this.Insert("\n");
             }
             else
             {
                 if (UICamera.controller.current != null)
                 {
                     UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                 }
                 UICamera.currentKey = this.mCam.submitKey0;
                 this.Submit();
             }
         }
         if (UICamera.GetKeyDown(this.mCam.submitKey1) || (this.mCam.submitKey1 == KeyCode.Return && UICamera.GetKeyDown(KeyCode.KeypadEnter)))
         {
             if (flag)
             {
                 this.Insert("\n");
             }
             else
             {
                 if (UICamera.controller.current != null)
                 {
                     UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                 }
                 UICamera.currentKey = this.mCam.submitKey1;
                 this.Submit();
             }
         }
         if (!this.mCam.useKeyboard && UICamera.GetKeyUp(KeyCode.Tab))
         {
             this.OnKey(KeyCode.Tab);
         }
     }
 }
Exemplo n.º 10
0
    /// <summary>
    /// Selection event, sent by UICamera.
    /// </summary>

    void OnSelect(bool isSelected)
    {
        if (isSelected)
        {
            current = this;
        }
        else if (current == this)
        {
            current = null;
        }

        if (label != null && enabled && gameObject.activeSelf)
        {
            if (isSelected)
            {
                mText = (label.text == mDefaultText) ? "" : label.text;
                //label.color = activeColor;
                if (isPassword)
                {
                    label.password = true;
                }

#if UNITY_IPHONE || UNITY_ANDROID
                if (Application.platform == RuntimePlatform.IPhonePlayer ||
                    Application.platform == RuntimePlatform.Android)
                {
#if UNITY_3_4
                    mKeyboard = iPhoneKeyboard.Open(mText);
#else
                    mKeyboard = TouchScreenKeyboard.Open(mText);
#endif
                }
                else
#endif
                {
                    Input.imeCompositionMode = IMECompositionMode.On;
                    Transform t      = label.cachedTransform;
                    Vector3   offset = label.pivotOffset;
                    offset.y += label.relativeSize.y;
                    offset    = t.TransformPoint(offset);
                    Input.compositionCursorPos = UICamera.currentCamera.WorldToScreenPoint(offset);
                    UpdateLabel();
                }
            }
#if UNITY_IPHONE || UNITY_ANDROID
            else if (mKeyboard != null)
            {
                mKeyboard.active = false;
            }
#endif
            else
            {
                if (string.IsNullOrEmpty(mText))
                {
                    label.text = mDefaultText;
                    //label.color = mDefaultColor;
                    if (isPassword)
                    {
                        label.password = false;
                    }
                }
                else
                {
                    label.text = mText;
                }

                label.showLastPasswordChar = false;
                Input.imeCompositionMode   = IMECompositionMode.Off;
            }
        }
    }
Exemplo n.º 11
0
 public void OpenSystemKeyboard()
 {
     keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumbersAndPunctuation, false, false, false, false);
     Debug.Log("OpenSystemKeyboard: Opening System Keyboard");
 }
Exemplo n.º 12
0
 public void OpenKeyBoard()
 {
     keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, true, true);
 }
Exemplo n.º 13
0
 public void callKeyboard()
 {
     TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, true);
     Debug.Log("Teclado ADM");
 }
Exemplo n.º 14
0
 public void openKeyboard()
 {
     TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NamePhonePad, false, false);
 }
Exemplo n.º 15
0
 public void OpenKeyboard()
 {
     touchScreenKeyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, false, false, "", 10);
 }
Exemplo n.º 16
0
 public void Activate()
 {
     TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
 }
    /// <summary>
    /// Actually do the Area Description save.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveCurrentAreaDescription()
    {
#if UNITY_EDITOR
        // Work around lack of on-screen keyboard in editor:
        if (m_displayGuiTextInput || m_saveThread != null)
        {
            yield break;
        }

        m_displayGuiTextInput  = true;
        m_guiTextInputContents = "Unnamed";
        while (m_displayGuiTextInput)
        {
            yield return(null);
        }

        bool saveConfirmed = m_guiTextInputResult;
#else
        if (TouchScreenKeyboard.visible || m_saveThread != null)
        {
            yield break;
        }

        TouchScreenKeyboard kb = TouchScreenKeyboard.Open("Unnamed");
        while (!kb.done && !kb.wasCanceled)
        {
            yield return(null);
        }

        bool saveConfirmed = kb.done;
#endif
        if (saveConfirmed)
        {
            // Disable interaction before saving.
            m_initialized = false;
            m_savingText.gameObject.SetActive(true);
            if (m_tangoApplication.m_areaDescriptionLearningMode)
            {
                string name = "";
                                #if UNITY_EDITOR
                name = m_guiTextInputContents;
                                #else
                name = kb.text;
                                #endif
                m_saveThread = new Thread(delegate()
                {
                    // Start saving process in another thread.
                    m_curAreaDescription = AreaDescription.SaveCurrent();
                    AreaDescription.Metadata metadata = m_curAreaDescription.GetMetadata();

                    metadata.m_name = name;

                    Debug.LogFormat("saveName: {0}", metadata.m_name);

                    m_curAreaDescription.SaveMetadata(metadata);

                    Debug.LogFormat("saveName: {0}", metadata.m_name);
                });
                m_saveThread.Start();
            }
            else
            {
                _SaveMarkerToDisk();
                #pragma warning disable 618
                Application.LoadLevel(Application.loadedLevel);
                #pragma warning restore 618
            }
        }
    }
Exemplo n.º 18
0
 public void openKeyboard()
 {
     TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumberPad, false, false, true, false);
 }
Exemplo n.º 19
0
 public void InputDetails()
 {
     TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NamePhonePad);
 }
Exemplo n.º 20
0
 protected void OnSelectEvent()
 {
     UIInput.selection = this;
     if (this.mDoInit)
     {
         this.Init();
     }
     if (this.label != null && NGUITools.GetActive(this))
     {
         this.label.color = this.activeTextColor;
         if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android)
         {
             UIInput.mKeyboard = ((this.inputType != UIInput.InputType.Password) ? TouchScreenKeyboard.Open(this.mValue, (TouchScreenKeyboardType)this.keyboardType, this.inputType == UIInput.InputType.AutoCorrect, this.label.multiLine, false, false, this.defaultText) : TouchScreenKeyboard.Open(this.mValue, TouchScreenKeyboardType.Default, false, false, true));
             if (Config.bANYSDK)
             {
             }
         }
         else
         {
             Vector2 compositionCursorPos = (!(UICamera.current != null) || !(UICamera.current.cachedCamera != null)) ? this.label.worldCorners[0] : UICamera.current.cachedCamera.WorldToScreenPoint(this.label.worldCorners[0]);
             compositionCursorPos.y     = (float)ResolutionConstrain.Instance.height - compositionCursorPos.y;
             Input.imeCompositionMode   = IMECompositionMode.On;
             Input.compositionCursorPos = compositionCursorPos;
             UIInput.mDrawStart         = 0;
         }
         this.UpdateLabel();
     }
 }
Exemplo n.º 21
0
    /// <summary>
    /// Selection event, sent by UICamera.
    /// </summary>

    void OnSelect(bool isSelected)
    {
        if (mDoInit)
        {
            Init();
        }

        if (label != null && enabled && NGUITools.GetActive(gameObject))
        {
            if (isSelected)
            {
                mText       = (label.text == mDefaultText) ? "" : label.text;
                label.color = activeColor;
                if (isPassword)
                {
                    label.password = true;
                }

#if UNITY_IPHONE || UNITY_ANDROID
                if (Application.platform == RuntimePlatform.IPhonePlayer ||
                    Application.platform == RuntimePlatform.Android)
                {
#if UNITY_3_4
                    mKeyboard = iPhoneKeyboard.Open(mText, (iPhoneKeyboardType)((int)type), autoCorrect);
#else
                    if (isPassword)
                    {
                        mKeyboard = TouchScreenKeyboard.Open(mText, TouchScreenKeyboardType.Default, false, false, true);
                    }
                    else
                    {
                        mKeyboard = TouchScreenKeyboard.Open(mText, (TouchScreenKeyboardType)((int)type), autoCorrect);
                    }
#endif
                }
                else
#endif
                {
                    Input.imeCompositionMode = IMECompositionMode.On;
                    Transform t      = label.cachedTransform;
                    Vector3   offset = label.pivotOffset;
                    offset.y += label.relativeSize.y;
                    offset    = t.TransformPoint(offset);
                    Input.compositionCursorPos = UICamera.currentCamera.WorldToScreenPoint(offset);
                }
                UpdateLabel();
            }
            else
            {
#if UNITY_IPHONE || UNITY_ANDROID
                if (mKeyboard != null)
                {
                    mKeyboard.active = false;
                }
#endif
                if (string.IsNullOrEmpty(mText))
                {
                    label.text  = mDefaultText;
                    label.color = mDefaultColor;
                    if (isPassword)
                    {
                        label.password = false;
                    }
                }
                else
                {
                    label.text = mText;
                }

                label.showLastPasswordChar = false;
                Input.imeCompositionMode   = IMECompositionMode.Off;
                RestoreLabel();
            }
        }
    }
Exemplo n.º 22
0
 public void OpenKeyboard()
 {
     myKeyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
 }
Exemplo n.º 23
0
 void OnMouseDown()
 {
     Debug.Log("opening touchscreen keyboard");
     keyboard = TouchScreenKeyboard.Open("name", TouchScreenKeyboardType.Default, false, false, false, false, "name");
 }
Exemplo n.º 24
0
 private void OnGUI()
 {
     //stringtoedit = GUI.TextField(new Rect(10, 10, 200, 30), stringtoedit, 30);
     stringtoedit = GameObject.Find("SubmitName").GetComponent <InputField>().text;
     kb           = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
 }
Exemplo n.º 25
0
 public void Keyboard()
 {
     TouchScreenKeyboard.Open(inputField.text);
 }
Exemplo n.º 26
0
 public void OpenKeyBoardAndroid(Image image)
 {
     ImageNameSelected = image.name;
     clavier           = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
 }
Exemplo n.º 27
0
    /// <summary>
    /// Update the text based on input.
    /// </summary>

    protected virtual void Update()
    {
#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            return;
        }
#endif
        if (isSelected)
        {
            if (mDoInit)
            {
                Init();
            }
#if MOBILE
            // Wait for the keyboard to open. Apparently mKeyboard.active will return 'false' for a while in some cases.
            if (mWaitForKeyboard)
            {
                if (mKeyboard != null && !mKeyboard.active)
                {
                    return;
                }
                mWaitForKeyboard = false;
            }
#endif
            // Unity has issues bringing up the keyboard properly if it's in "hideInput" mode and you happen
            // to select one input in the same Update as de-selecting another.
            if (mSelectMe != -1 && mSelectMe != Time.frameCount)
            {
                mSelectMe       = -1;
                mSelectionEnd   = string.IsNullOrEmpty(mValue) ? 0 : mValue.Length;
                mDrawStart      = 0;
                mSelectionStart = selectAllTextOnFocus ? 0 : mSelectionEnd;
                label.color     = activeTextColor;
#if MOBILE
                RuntimePlatform pf = Application.platform;
                if (pf == RuntimePlatform.IPhonePlayer ||
                    pf == RuntimePlatform.Android ||
                    pf == RuntimePlatform.WP8Player
 #if UNITY_4_3
                    || pf == RuntimePlatform.BB10Player
 #else
                    || pf == RuntimePlatform.BlackBerryPlayer ||
                    pf == RuntimePlatform.MetroPlayerARM ||
                    pf == RuntimePlatform.MetroPlayerX64 ||
                    pf == RuntimePlatform.MetroPlayerX86
 #endif
                    )
                {
                    string val;
                    TouchScreenKeyboardType kt;

                    if (inputShouldBeHidden)
                    {
                        TouchScreenKeyboard.hideInput = true;
                        kt = (TouchScreenKeyboardType)((int)keyboardType);
 #if UNITY_METRO
                        val = "";
 #else
                        val = "|";
 #endif
                    }
                    else if (inputType == InputType.Password)
                    {
                        TouchScreenKeyboard.hideInput = false;
                        kt              = TouchScreenKeyboardType.Default;
                        val             = mValue;
                        mSelectionStart = mSelectionEnd;
                    }
                    else
                    {
                        TouchScreenKeyboard.hideInput = false;
                        kt              = (TouchScreenKeyboardType)((int)keyboardType);
                        val             = mValue;
                        mSelectionStart = mSelectionEnd;
                    }

                    mWaitForKeyboard = true;
                    mKeyboard        = (inputType == InputType.Password) ?
                                       TouchScreenKeyboard.Open(val, kt, false, false, true) :
                                       TouchScreenKeyboard.Open(val, kt, !inputShouldBeHidden && inputType == InputType.AutoCorrect,
                                                                label.multiLine && !hideInput, false, false, defaultText);
 #if UNITY_METRO
                    mKeyboard.active = true;
 #endif
                }
                else
#endif // MOBILE
                {
                    Vector2 pos = (UICamera.current != null && UICamera.current.cachedCamera != null) ?
                                  UICamera.current.cachedCamera.WorldToScreenPoint(label.worldCorners[0]) :
                                  label.worldCorners[0];
                    pos.y = Screen.height - pos.y;
                    Input.imeCompositionMode   = IMECompositionMode.On;
                    Input.compositionCursorPos = pos;
                }

                UpdateLabel();
                if (string.IsNullOrEmpty(Input.inputString))
                {
                    return;
                }
            }
#if MOBILE
            if (mKeyboard != null)
            {
 #if UNITY_METRO
                string text = Input.inputString;
                if (!string.IsNullOrEmpty(text))
                {
                    Insert(text);
                }
 #else
                string text = mKeyboard.text;

                if (inputShouldBeHidden)
                {
                    if (text != "|")
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            Insert(text.Substring(1));
                        }
                        else
                        {
                            DoBackspace();
                        }

                        mKeyboard.text = "|";
                    }
                }
                else if (mCached != text)
                {
                    mCached = text;
                    value   = text;
                }
 #endif // UNITY_METRO
                if (mKeyboard.done || !mKeyboard.active)
                {
                    if (!mKeyboard.wasCanceled)
                    {
                        Submit();
                    }
                    mKeyboard  = null;
                    isSelected = false;
                    mCached    = "";
                }
            }
            else
#endif // MOBILE
            {
                string ime = Input.compositionString;

                // There seems to be an inconsistency between IME on Windows, and IME on OSX.
                // On Windows, Input.inputString is always empty while IME is active. On the OSX it is not.
                if (string.IsNullOrEmpty(ime) && !string.IsNullOrEmpty(Input.inputString))
                {
                    // Process input ignoring non-printable characters as they are not consistent.
                    // Windows has them, OSX may not. They get handled inside OnGUI() instead.
                    string s = Input.inputString;

                    for (int i = 0; i < s.Length; ++i)
                    {
                        char ch = s[i];
                        if (ch < ' ')
                        {
                            continue;
                        }

                        // OSX inserts these characters for arrow keys
                        if (ch == '\uF700')
                        {
                            continue;
                        }
                        if (ch == '\uF701')
                        {
                            continue;
                        }
                        if (ch == '\uF702')
                        {
                            continue;
                        }
                        if (ch == '\uF703')
                        {
                            continue;
                        }

                        Insert(ch.ToString());
                    }
                }

                // Append IME composition
                if (mLastIME != ime)
                {
                    mSelectionEnd = string.IsNullOrEmpty(ime) ? mSelectionStart : mValue.Length + ime.Length;
                    mLastIME      = ime;
                    UpdateLabel();
                    ExecuteOnChange();
                }
            }

            // Blink the caret
            if (mCaret != null && mNextBlink < RealTime.time)
            {
                mNextBlink     = RealTime.time + 0.5f;
                mCaret.enabled = !mCaret.enabled;
            }

            // If the label's final alpha changes, we need to update the drawn geometry,
            // or the highlight widgets (which have their geometry set manually) won't update.
            if (isSelected && mLastAlpha != label.finalAlpha)
            {
                UpdateLabel();
            }

            // Having this in OnGUI causes issues because Input.inputString gets updated *after* OnGUI, apparently...
            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
            {
                bool newLine = (onReturnKey == OnReturnKey.NewLine) ||
                               (onReturnKey == OnReturnKey.Default &&
                                label.multiLine && !Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl) &&
                                label.overflowMethod != UILabel.Overflow.ClampContent &&
                                validation == Validation.None);

                if (newLine)
                {
                    Insert("\n");
                }
                else
                {
                    UICamera.currentScheme = UICamera.ControlScheme.Controller;
                    UICamera.currentKey    = KeyCode.Return;
                    Submit();
                    UICamera.currentKey = KeyCode.None;
                }
            }
        }
    }
Exemplo n.º 28
0
 public void OpenKeyboard()
 {
     lavie = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumberPad);
 }
Exemplo n.º 29
0
 // Start is called before the first frame update
 void OnEnable()
 {
     keyboard = TouchScreenKeyboard.Open(text, TouchScreenKeyboardType.Default);
     StartCoroutine("EnableKeyboard");
 }
Exemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        //adding score and show in scoreText
        for (int i = 0; i < leftPlayers.Length; i++)
        {
            if (leftPlayers[i] != null)
            {
                score += leftPlayers[i].GetComponent <ShapeController>().getPoints();
                leftPlayers[i].GetComponent <ShapeController>().setPointsToZero();
            }

            if (rightPlayers[i] != null)
            {
                score += rightPlayers[i].GetComponent <ShapeController>().getPoints();
                rightPlayers[i].GetComponent <ShapeController>().setPointsToZero();
            }
        }

        if (end < 3 && end >= 0)
        {
            end = destroyWall.GetComponent <OnWallDestroy>().end;
        }

        scoreText.text = "" + score;

        if (end > 2)
        {
            gameOverSound.Play();

            //on defeat check high score, if new rewrite actual
            canvas.SetActive(true);
            highScoresTexts[1].text = "" + score;
            for (int i = 0; i < 5; i++)
            {
                if (score >= PlayerPrefs.GetInt("highScore" + i))
                {
                    //move old highscores one place down
                    for (int j = 4; j > i; j--)
                    {
                        PlayerPrefs.SetInt("highScore" + j, PlayerPrefs.GetInt("highScore" + (j - 1)));
                        PlayerPrefs.SetString("highScoreName" + j, PlayerPrefs.GetString("highScoreName" + (j - 1)));
                    }
                    //open keyboard
                    keyBoard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);

                    //set right text for high score
                    highScoresTexts[0].text = "New Highscore : ";
                    highScoresTexts[2].gameObject.SetActive(true);
                    PlayerPrefs.SetInt("highScore" + i, score);
                    tmpNumber = i;
                    break;
                }
                else
                {
                    highScoresTexts[0].text = "Your score : ";
                }
            }
            end = -1;
        }

        //set player name on new high score
        if (keyBoard != null && keyBoard.done)
        {
            highScoresTexts[3].text = keyBoard.text;
            PlayerPrefs.SetString("highScoreName" + tmpNumber, keyBoard.text);
        }
    }