Search Unity

Keyboard Input

Discussion in 'PSM' started by Xemenas, Apr 19, 2014.

  1. Xemenas

    Xemenas

    Joined:
    Sep 10, 2012
    Posts:
    28
    Hey everyone,

    I just downloaded the Beta last night so forgive me if I've missed a thread or document that talks about this. (if there is please direct me to it!)

    I was using Unity's GUI to do some basic tests on the Vita, but using textfield doesn't pull up the keyboard, and trying to use TouchScreenKeyboard.Open(string) sporadically loads the keyboard for a frame and then closes it.

    Has anyone figured out a way to use the keyboard?

    Thanks!
     
  2. jesusluvsyooh

    jesusluvsyooh

    Joined:
    Jan 10, 2012
    Posts:
    377
    This does it for me, i simplified it slightly so its easier to understand and doesn't have all my project specific crap with it 8)

    Code (csharp):
    1. private var keyboard : TouchScreenKeyboard;
    2. private var inputField = "";  //text input variable
    3.  
    4. function OnGUI ()
    5. {
    6. if (GUI.Button(Rect (40*widthScale, 235*heightScale, 365*widthScale, 45*heightScale), inputField))
    7. {
    8.    var keyboard = TouchScreenKeyboard.Open(inputField, TouchScreenKeyboardType.Default);
    9. }
    10.  
    11. if (keyboard)
    12. {
    13.    if (keyboard.active)
    14.    {
    15.      inputField = keyboard.text;
    16.    }
    17. }
    18.  
    19. }
     
    Last edited: Nov 4, 2014
  3. Xemenas

    Xemenas

    Joined:
    Sep 10, 2012
    Posts:
    28
    Awesome, that was exactly what I need. Thank you! I guess I should have followed the example with the documentation rather than just trying my own thing...