Search Unity

Hidden Mobile Input

Discussion in 'Android' started by Edgaras-Randis, Mar 14, 2015.

  1. Edgaras-Randis

    Edgaras-Randis

    Joined:
    Jul 8, 2014
    Posts:
    20
    OK, here's one thing from the "what's new in Unity 5".

    "
    ANDROID
    • Disabled hidden input keyboard.
    "

    The thing is that I relied on that feature. Most of the time during the game, keyboard will be opened. Now after this feature is gone, how can I bring it back and why was it dropped in the first place?
     
  2. sumeeton

    sumeeton

    Joined:
    Mar 1, 2015
    Posts:
    18
    It seems broken. Just report it as a bug. It's really annoying. It wasn't working earlier when hide mobile input was enabled and now they completely ruined it. :mad:
     
  3. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    524
    So, the thing is that according to the Android spec soft keyboards are not required to send KeyEvents when keys are pressed. And if no KeyEvents are issued then there is no way for Unity to know which key was pressed. More and more keyboards are taking advantage of this and only works in conjunction with a text field. This is very bad for game applications but that is the reality. Essentially the only keyboards required to send KeyEvents are hardware keyboards.

    If anyone knows of any workarounds or solutions to this problem please let us know.

    If you are targeting a finite set of devices which you know support hidden input. What you can do is open the keyboard yourself by calling into java. It's pretty easy to open a keyboard and if the keyboard is emitting KeyEvents it should work.

    The java code for opening and closing a keyboard looks something like this:
    Code (csharp):
    1. InputMethodManager imm = context.getSystemService(Context.INPUT_METHOD_SERVICE);
    2. imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); // open keyboard
    3. imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY); // close keyboard
    You can use the AndroidJava* classes to do this from a C# script. One thing though, since this is going to open a window it needs to be called on the UI thread. There is an example how to do that here AndroidJavaRunnable.
     
    mulova and sumeeton like this.
  4. sumeeton

    sumeeton

    Joined:
    Mar 1, 2015
    Posts:
    18
    Okay. I get it now. But why did Hide Mobile Input worked before? Like you could still type in text to Input Field without the text box, although the delete key event didn't work and there was no way to select the text.
     
  5. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    524
    In the past LatinIME has worked reasonably well but many of the other keyboards did not. Here is some information on the problems related to LatinIME in particular.
    http://stackoverflow.com/questions/...kspace-delete-press-in-soft-keyboard/19980975

    At some point we will probably revisit this and try to make it work. But ever since we added support for hidden input field, it has been causing more harm than good :-(
     
    sumeeton likes this.
  6. sumeeton

    sumeeton

    Joined:
    Mar 1, 2015
    Posts:
    18
    Alright! I'm satisfied with your answer. I am happy with the input text box since there's at least a way to get the input.
    One more question though. Can I change the texture of the input box and the ok button? Or hide the OK button?
     
  7. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    524
    We have started working on that but nothing has been released yet. - yes, we are aware the current layout/style looks like @#$.
     
  8. sumeeton

    sumeeton

    Joined:
    Mar 1, 2015
    Posts:
    18
  9. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    346
    So just to follow up on this hidden input on Android thing... is Unity still working on improvements or did we punt here?

    I see the status on this ticket:
    http://issuetracker.unity3d.com/iss...doesnt-work-properly-when-turned-to-landscape
    is "wont fix".

    I also see however that Yury mentioned just on Apr 14th that a patch is coming. The patch release that came out on Apr 15th didn't resolve the issue for us (in 5.0.1p1) so I'm hoping this is still in process. Is that the case? Can we expect something in future patch to add support back for hidden input on Android? Any ETA at all?
     
  10. OldGamer

    OldGamer

    Joined:
    Apr 20, 2015
    Posts:
    3
    Last edited: May 2, 2015
  11. lazism

    lazism

    Joined:
    Dec 29, 2014
    Posts:
    1
    i got same problem. it was not fixed on unity5 and i'm using lastest version now.
     
  12. cheywood

    cheywood

    Joined:
    Dec 10, 2013
    Posts:
    10
    Any news from Unity on this one? Is there a specific ticket for this issue?

    The current Android solution is hella ugly!

    Thanks
     
    larku likes this.
  13. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,180
    Bitter, I'm trying to do a plugin to be able to get the keyboard, but I can't get the text and behavior. Basically it's a mess to try to get it to work with a plugin and the current system.

    Using this:
    1. InputMethodManager imm = context.getSystemService(Context.INPUT_METHOD_SERVICE);
    2. imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); // open keyboard
    3. imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY); // close keyboard
    Any ideas? I'm not able to get the entered text returned to the screen. I'm trying to create a wrapper around it to replace the standard TouchScreenKeyboard with no luck.
     
  14. nicholausadi

    nicholausadi

    Joined:
    Jun 25, 2013
    Posts:
    4
    I'm using unity 5.3.1f1 and when check Hide Input Mobile and also add TouchScreenKeyboard.hideInput = true; and mainInputField.shouldHideMobileInput = true; , I still get input like that. Any solution to hide or replace inputfield with custom inputfield?
    Note : I'm using UI Canvas InputField.
     

    Attached Files:

  15. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,412

    Did you read this thread? It explains exactly what's going on and the only current known workaround.
     
  16. Dexydon

    Dexydon

    Joined:
    Dec 20, 2015
    Posts:
    10
    The same problem
     
  17. FISH_SAMA

    FISH_SAMA

    Joined:
    Oct 17, 2016
    Posts:
    1

    Is that fixed in any new version now?
     
    rjth likes this.
  18. ChinaLight

    ChinaLight

    Joined:
    Jan 7, 2017
    Posts:
    2
    Have you found a way to hide it? The same question:(
     
  19. ChinaLight

    ChinaLight

    Joined:
    Jan 7, 2017
    Posts:
    2
    Have you found a way to hide it? The same question
     
  20. mopsicus

    mopsicus

    Joined:
    Feb 15, 2016
    Posts:
    13
  21. AETechron

    AETechron

    Joined:
    Aug 9, 2016
    Posts:
    6
    My coworker and I are developing a Unity application for a specific Android device which has no touchscreen and relies on a keyboard and mouse for input. It's incredibly jarring to click an inputfield and to type into an intermediary "mobile" inputfield when we are using a mouse and keyboard.

    You say that hardware keyboards send the necessary KeyEvents for Unity's input system, so is there any way to take advantage of that for my project? Can I somehow force the mobile inputfield off?

    This is a major hurdle for the project we are working on and we've gone down the path of creating our own custom inputfield but it is time consuming and requires a TON of validation on our part. I have hope that there's SOME better solution out there.

    Thank you,
    Sid Hays
     
  22. tydygunn

    tydygunn

    Joined:
    Aug 9, 2012
    Posts:
    13
    Could we can an official Unity response on this? It's been just shy of 2 years since this thread started and I can't find any info about whether they're working on this or not. Unity's a big enough product that they should have contacts inside of Google that they can work with to try to get this all sorted out. I know it's nowhere near this simple, but just an acknowledgement that it's being worked on or a statement that it's been given up on would be great.

    Mopsicus's hack is great, but then you can't take advantage of all the built in InputField features then such as text highlighting, displaying a carret, hiding password input, displaying different keyboard types (normal, email, dial pad, etc), and many other features.
     
    bsozay likes this.
  23. Jairolaya12x

    Jairolaya12x

    Joined:
    Dec 22, 2014
    Posts:
    3
  24. tydygunn

    tydygunn

    Joined:
    Aug 9, 2012
    Posts:
    13
  25. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,195
    So can not Unity use either mopsicus's hack or allow a smaller text input field above the keyboard (on android [samsung] phones in landscape the keyboard and text box cover the entire screen!)
     
  26. Hemaolle

    Hemaolle

    Joined:
    Jun 25, 2013
    Posts:
    9
    Let me share this native edit plugin here that we've been using at Yousician: https://github.com/YousicianGit/UnityNativeEdit. The idea is to place a native input field on top of the Unity input field and hide the Unity input field. This way we get also copy pasting and text highlighting. We forked from a bit older project and have been using it for some time now. It's not perfect but works pretty nicely for us. Would be great to get more people using it and collaborating on the codebase.
     
    larku likes this.
  27. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    149
    I've check Unity 5.6.1 but he problem still exists. Any try from Unity technologies for fixing this problem from many time ago ?
     
  28. Mukabr

    Mukabr

    Joined:
    Jun 10, 2013
    Posts:
    60
    Any news regarding this topic?
     
  29. alizbliz

    alizbliz

    Joined:
    Mar 15, 2017
    Posts:
    4
    Guys, do you have any news ?
    I tested several solutions found on the web, but nothing works.
     
  30. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    796
    Agreed, and for this reason we really need a work around. Not possible to have any user input fields in the app without making our app look so bad.
     
  31. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,073
    This should be fixed - in landscape, the keyboard is no longer taking the whole screen.
     
  32. htmoore

    htmoore

    Joined:
    Nov 18, 2016
    Posts:
    6
    Seems this issue has been going on for years and still no solution??? :-(
     
  33. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,195
    The landscape keyboard entry is no longer fullscreen in latest Unity.

    This looks like it
    5.6.2: Android: Make SoftInput not take fullscreen on landscape orientation. (905581)

    Can it be back ported to 5.5.x any way?
     
    Last edited: Oct 26, 2017
  34. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    419
    In 5.5 it should be present starting with 5.5.4p1, in 5.6 - starting with 5.6.1p2 and it should be present in all 2017.1 and 2017.2 versions.
     
    andyz likes this.
  35. AETechron

    AETechron

    Joined:
    Aug 9, 2016
    Posts:
    6
    Reiterating my post above: https://forum.unity.com/threads/hidden-mobile-input.310709/#post-2928284

    We are developing an app that uses ONLY hardware keyboard input. Our hardware has no touchscreen. Since it sounds like a hardware keyboard is sufficient, can we somehow disable mobile input entirely for our app? We would be forever grateful. We just want to get rid of the intermediary input field.

    Thank you.
     
  36. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,073
    Sounds like it's not doable out-of-box at the moment.
    Can you hook up to onKeyUp()/onKeyDown() events in the Activity?
    Anyway, it requires some plugin coding.
     
  37. sminjard

    sminjard

    Joined:
    Sep 21, 2017
    Posts:
    4
    I guess there is still no way to hide the keyboard input box on android but is there a way to customize its layout now?
     
  38. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    796
    Like, move it completely offscreen so we can handle the rendering of the box ourselves? :p Is there a way to do this @Yury-Habets
     
  39. clockfree

    clockfree

    Joined:
    Feb 2, 2015
    Posts:
    31
    any news guys? :mad:
     
  40. clockfree

    clockfree

    Joined:
    Feb 2, 2015
    Posts:
    31
    TheKingOfTheRoad likes this.
  41. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,073
    Unfortunately not (at least a straightforward one).
     
  42. Tony-Studio

    Tony-Studio

    Joined:
    Dec 18, 2017
    Posts:
    1
    On my Galaxy S6, using your plugin, the fields are never filled. It's because Input.inputString is always empty even if I type.
    If you could add the source of your plugin I think it would be easy to add a java method to retrieve it, but I dont see native sources :(
    EDIT : after restarting the app (no rebuilding), fields are filled. So it looks like it is not quite stable. Also "most common propositions" never update themselves, space key does close the keyboard.
    Can't really recommand it at this point.
     
    Last edited: Jan 23, 2018
    konsnos likes this.
  43. neel49

    neel49

    Joined:
    Dec 30, 2016
    Posts:
    1
    i have used the plugin https://github.com/mopsicus/unity-keyboard-hack and it worked fine but it still allowing to copy/paste in inputbox and i don't want to allow a user to paste the text in input box
    how to do this please help me
     
  44. EricTViking

    EricTViking

    Joined:
    Oct 11, 2014
    Posts:
    4
    Thanks to Mopsicus for the "Hack" - got me up and running. But this really ought to be sorted in Unity! I just lost an hour and a half fighting this issue and now the solution I'm using doesn't allow for text entry from the keyboard when I'm debugging. C'mon guys, let's get this sorted as there must be more than a few people that need to use text input on Android without having a great big numpty white text box appearing above the on screen keyboard...

    [Edit] Had to give up on the Mopsicus hack as it caused my app to crash if the input field was tapped several times. Also the lack of a caret was a bit of a bummer. Appreciate the effort though.

    Am currently working with this which is pretty promising - https://github.com/YousicianGit/UnityNativeEdit
     
    Last edited: Sep 27, 2018
  45. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    796
    Hey Yury, can you expand on why this is the case? It seems so trivial but clearly it isn't. What is the blocker? The input box just looks really bad.
     
    EricTViking likes this.
  46. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,073
    @Prodigga there's some legacy mystery around it.
    To make the hidden input, one needs to use native input system. It used to have multiple issues on different devices.
     
  47. Hamza_Mushtaq

    Hamza_Mushtaq

    Joined:
    Jul 31, 2018
    Posts:
    1
    is this issue solved yet ?
     
  48. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    796
    I think I saw in the alpha something about rendering the input field offscreen? Is this it? Does this achieve what we're after?