Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Forcing an ASCII keyboard on device set to non-ASCII language

Discussion in 'UGUI & TextMesh Pro' started by BillyGraban, Sep 9, 2020.

  1. BillyGraban

    BillyGraban

    Joined:
    Apr 1, 2020
    Posts:
    7
    I have some development requirements that have really stumped me. Our login page must only allow ascii characters to be entered for the username, but if a device is set to Japanese, the default Japanese keyboard shows up.

    We are using TMPro 2.1.1. Password fields always show the ascii keyboard but have the unwanted feature of hiding the text as the user types. I've tried using Custom/ASCII Capable, but that still displays the default Japanese keyboard.

    I have also tried setting the default keyboard type to password, and then swapping to alphanumeric once the field is focused, but that has bad side effects like:
    * When reselecting the field all previous text will convert to asterisks

    I would be thankful for any suggestions or directions
     
  2. BillyGraban

    BillyGraban

    Joined:
    Apr 1, 2020
    Posts:
    7
    This was a fairly drastic solution, but I was able to find a workaround. I embedded TMPro into the project so I could modify the source. I added an extra boolean to TMP_InputField that would allow the field to display the password as plain text. I set the username field to have a content type of password and enabled the display password option.

    Finally I removed the white input box above the soft keyboard, as that would still display as a 'password' type.
     
  3. BillyGraban

    BillyGraban

    Joined:
    Apr 1, 2020
    Posts:
    7
    I'll have to walk this answer back. After testing I discovered that the Back button was causing a 5s hang in the engine. Here are the relevant logs:

    I/InputDispatcher: Application is not responding: AppWindowToken{3fbf639 token=Token{7171e00 ActivityRecord{f207c83 u0 com.company.product/com.company.plugins.companyunity.CompanyServiceActivity t3606}}}.  It has been 5010.6ms since event, 5005.4ms since wait started.  Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.
    I/WindowManager: Input event dispatching timed out . Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.
    W/InputDispatcher: Asynchronous input event injection timed out.