Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Allowing Phone Keyboard Input?

Discussion in 'Scripting' started by GoodNight9, Mar 30, 2021.

  1. GoodNight9

    GoodNight9

    Joined:
    Dec 29, 2013
    Posts:
    123

    Hello!

    I have a button, when the user clicks it I would like it to open the mobile keyboard. I'm having trouble finding what the code to activate that. My Button method looks like this so far:
    https://ibb.co/kSWCgq5 (Image of Problem)

    Code (CSharp):
    1.     public void UserKeyboardInput()
    2.     {
    3.         //What's the code for this??
    4.     }
    Thank you for your time!
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
  3. GoodNight9

    GoodNight9

    Joined:
    Dec 29, 2013
    Posts:
    123
    Thank you for sharing that. When I put the code in my update method nothing happens though during runtime. The keyboard does not appear (Testing it on PC at the moment)

    Here is my code :

    Code (CSharp):
    1.     public void UserKeyboardInput()
    2.     {
    3.         TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, true, true);
    4.     }
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Try putting it in OnGUI()
     
  5. GoodNight9

    GoodNight9

    Joined:
    Dec 29, 2013
    Posts:
    123
    Hmmm, I tried but it doesn't seem to activate. I've recorded what my screen looks like when I run the code. I feel like I'm real close, but just missing something small :(
     
  6. seejayjames

    seejayjames

    Joined:
    Jan 28, 2013
    Posts:
    685
    Pretty sure nothing happens on PC, it has to be built to the actual device.
     
    GoodNight9 and PraetorBlue like this.
  7. GoodNight9

    GoodNight9

    Joined:
    Dec 29, 2013
    Posts:
    123
    Ohhhh OK, I'll have to test it for real then.
    Thank you-!
     
  8. Digital_Owl

    Digital_Owl

    Joined:
    Feb 7, 2021
    Posts:
    46
    hey! i have the same problem, i can't really make the keyboard show when running the game ( also testing on pc ) how do i know if its working or not if it can not be shown on pc? Thanks
     
  9. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    Touchscreenkeyboard is part of the OS, and thus does not exist on PC.
    The only way to test it is to make a build, or use Unity Remote.