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

InputField not working on mobile?

Discussion in 'UGUI & TextMesh Pro' started by RogueCode, Aug 26, 2014.

  1. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    I feel like I must be doing something really stupid. I can deploy the example UI project to my Windows Phone and the InputFields work fine (in the Widget scene).
    But when I add my own (even in that same scene) they don't. Tapping on them brings up the phones keyboard, but the actual text is not selected and it seems like the control doesn't get focused. Typing does nothing.
    The really weird thing is that 1 of every 10 or so taps actually works perfectly, but not the rest of the time.
    I've tried constructing my input fields property-per-property exactly as the example ones, and they still don't work.

    I tried copying one of the two example InputFields to a different place on the scene and it seems like that has completely broken them all.

    These all work 100% on PC.
     
    CDMcGwire likes this.
  2. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    Nobody? This seems like a pretty big issue :(
     
  3. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,181
    Raise a bug describing the steps + a repro project. They work fine for us on windows phone in our test cases.
     
  4. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    Thanks, I've done this.

    Repo steps are quite easy :p
    "create a new project, add a InputField, then run the project on the phone."
     
  5. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,181
    Sure :) It's more for us to track the issue + bugs with projects get higher priority in our incoming bug quality rating system.
     
  6. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    FWIW, if anyone else experiences this, Unity has confirmed it's a bug.
     
  7. CDMcGwire

    CDMcGwire

    Joined:
    Aug 30, 2014
    Posts:
    133
    I was starting to wonder if I was alone on this issue. Glad to see it's already been acknowledged.
     
  8. tkoknordic

    tkoknordic

    Joined:
    Jan 31, 2013
    Posts:
    93
    Any movements there? I have same problem with Unity 5.0 and I just updated to the 5.0f1 and still same problem with our Android build. Inputfield gets the focus but onscreen keyboard doesn't show up. I have tried it with Nvidia shield tablet, Samsung galaxy tab 2 and with LG Nexus 5. Everything Works on pc. I also made one plain test scene only with three inputfields and eventmanager. It didn't work.

    Edit:
    I think my problem is related to issue 660653: http://issuetracker.unity3d.com/issues/u4-dot-6-metal-seed-1-can-no-longer-use-input-field-on-ios

    The issue is already fixed in U4.6.2 and I hope it will soon come to next U5.0 release.
     
    Last edited: Feb 10, 2015
  9. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,364
    THIS BUG IS STILL NOT FIXED IN UNITY 4.6.4f!!!! AHHHHH!!!!

    Please tell a workaround! I need it urgently for a pubilshed game!!! :eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek::eek:

    There's not point doing a bug report because they just delete the bug report without fixing it!
     
  10. tkoknordic

    tkoknordic

    Joined:
    Jan 31, 2013
    Posts:
    93
    My workaround was old gui input field wiht custom GUISkin.
    • "PasswordInput" variable is my uGui inputfield gameobject in the scene.
    • "password_default" is string variable with place holder text.
    • I used widthScaler and heightScaler floats because my orginal uGui is releative to screen size, so I can set dimensions of my input fields as percentages of screen size.

    Code (CSharp):
    1.  
    2. void OnGUI()
    3.     {
    4.         GUI.skin = skin;
    5.         int width = Mathf.RoundToInt(Screen.width / widthScaler);
    6.         int height = Mathf.RoundToInt(width / heightScaler);
    7.         GUI.skin.textField.fontSize = Mathf.RoundToInt(height / fontscaler);
    8.  
    9.         if (passwordInput.gameObject.activeSelf)
    10.         {
    11.             Vector3 position = Camera.main.WorldToScreenPoint(passwordInput.transform.position);
    12.  
    13.             GUI.SetNextControlName("password_field");
    14.             passugui = GUI.PasswordField(new Rect(Mathf.RoundToInt(position.x) - width / 2, Screen.height - Mathf.RoundToInt(position.y) - height / 2, width, height), passugui,'*');
    15.  
    16.             if (UnityEngine.Event.current.type == EventType.Repaint)
    17.             {
    18.                 if (GUI.GetNameOfFocusedControl() == "password_field")
    19.                 {
    20.                     if (passugui == password_default) passugui = "";
    21.                 }
    22.                 else
    23.                 {
    24.                     if (passugui == "") passugui = password_default;
    25.                 }
    26.             }
    27.         }
    28. }
     
  11. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,364
    Thanks. I may do something like this. Probably have an off-screen old GUI input and link that to the uGUI text field.
     
  12. yoonitee

    yoonitee

    Joined:
    Jun 27, 2013
    Posts:
    2,364
    I've come up with a quick and dirty fix. It checks to see if the text has disappeared and if so uses the last stored value: (This is a fix for the problem of text in the textfield disappearing after you type it)

    Code (CSharp):
    1.     string tempvalue="";
    2.  
    3.     public void ValueChange(string s){
    4.         //Fix for Android: Prevent text disapearing after input
    5.         if((s=="" || s==null) && tempvalue.Length>1) {
    6.             s = tempvalue;
    7.         }
    8.         else tempvalue = s;
    9.     }
    10.  
    11.     public void EndEdit(string s){
    12.         //fix for Android: If text has disapeared use last available:
    13.         if(s=="" && tempvalue!="") {
    14.             s = tempvalue;
    15.             inputfield.text = tempvalue;
    16.         }
    17.         //do something with value
    18.         text2.text = s;
    19.     }
    It also prevents you from deleting all the text in a textfield in one go. But I think that's a small price to pay.

    Happy with that. :) Me-1 Unity-0

    Unless anyone's got a better solution they could share?
     
    Last edited: Apr 8, 2015
  13. cyritschie

    cyritschie

    Joined:
    Apr 17, 2015
    Posts:
    1
    Setting the vertical text alignment of the Text and Placeholder Objects to top and reassigning them to the InputField Object fixed this for me.