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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question Inputfield processing not fast enough on Android

Discussion in 'UGUI & TextMesh Pro' started by christianstrang, Sep 13, 2022.

  1. christianstrang

    christianstrang

    Joined:
    Aug 6, 2013
    Posts:
    29
    Hi there,
    I'm currently working on a typing game on mobile where the inputfield is processed when the user presses space. E.g. these are the words: "house hello world you again now"
    The user types in the inputfield "house" and once he presses "space" the input is compared with the first word "house" and if it matches he moves on to the next word and the current input is removed (the space included).
    This works fine in the editor but on android, if you type quickly enough, the first letter after pressing "space" is not inserted into the inputfield (you have to wait approximately 300ms after pressing space for the input to be recognized).

    Now I tried a lot of different things but it seems that the inputfield is unresponsive during the process, any idea what could cause that or how to circumvent it? Here is some example code:

    Code (CSharp):
    1.  
    2.     void Start()
    3.     {
    4.         inputField.Select();
    5.         inputField.onValueChanged.AddListener(UpdateInputField);
    6.     }
    7.  
    8.     public void UpdateInputField(string inputText)
    9.     {
    10.         // Listen for space inside inputfield
    11.         if (inputText.Contains(" "))
    12.         {
    13.            ...
    14.         }
    15.     }
    16.  
    Do I have to update the inputfield differently than just
    inputField.text = ""
    to avoid blocking of new input?
     
    Last edited: Sep 16, 2022
  2. christianstrang

    christianstrang

    Joined:
    Aug 6, 2013
    Posts:
    29
    I recreated the project with the minimum codebase to reproduce the issue:
    https://drive.google.com/file/d/1-Ezpc9i9dABoJtR1z-NkNwcNDiI98i1h/view?usp=sharing

    Just build the project for android and on your phone, type the first word, check what the first letter of the next word is, then press space and immediately afterwards the beforementioned first letter and you'll see, that the letter is not placed in the inputfield.

    I type quite fast on my phone and have this issue with about every third or fourth word, not sure if its my code or generally an issue with the inputfield :/