Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bugs happen when typing Chinese words in Editor and UI

Discussion in 'UGUI & TextMesh Pro' started by better_walk_away, Dec 19, 2018.

  1. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Hello,

    I found that Unity Editor and Unity's build-in UIs are very buggy when it comes to typing Chinese words. I have submitted a bug report to Unity yesterday. There are many users that would be typing Chinese words in Unity and Input Field, but surprisingly I didn't find any post in the issue tracker that are mentioning these issues. My game is largely based on Chinese words and I need to type Chinese in the Editor, these bugs have caused hindrance to my development. So I spent some time writing bug report and recorded a video, and here is my bug report:

    I am using Unity 2018.2.18f1 (now I have upgraded to 2018.3.f02, but the bugs still exist) and I am a Unity Plus user, my operational system is Windows 10.

    I am going to report 4 bugs here:

    Bug#1

    I am using "Microsoft Bopomofo" to type Chinese characters in the input field of Inspector. I found that if I don't hit Enter to confirm the typing and click somewhere else, the characters that I inputted will be duplicated for unknown reason, there is certainly something wrong with the Unity's source code. After the bug occurs, we won’t be able to type Chinese until we hit “Ctrl” + “Space”.

    Bug#2

    The same issue happens when I create a Unity's build-in Input Field UI, and then I run the game, after typing some Chinese characters in the Input Field using "Microsoft Bopomofo" and not hitting the Enter key, I click somewhere else, the Chinese characters in the Input Field get duplicated.

    Bug#3

    If I create multiple Unity's build-in Input Fields and replace the fonts of Input Field, both placeholder and text, with a Chinese font, run the game, type some Chinese characters in the first input field without hitting Enter, and then type some Chinese characters in the second input field without hitting Enter again, Unity will throw an error message and the text of every input field glitches for unknown reason.

    Bug#4
    Once we reproduce either Bug#1 or Bug#2, we won't be able to type Chinese in Unity or in the build-in Input Field UI, but we still can type Chinese on other software other than Unity or the game that is built with Unity. We have to hit "Ctrl"+"Space" to be able to type Chinese again.

    I have attached a video file named “Bugs Reproducing Demostration.wmv” showing how exactly we can reproduce the bugs.

    Here are the instructions to reproduce the bugs:

    Bug#1

    Step1: create a brand-new Unity project

    Step2: create a build-in Text UI

    Step3: type some Chinese characters in the input field of the Text component in the inspector without hitting Enter key

    Step4: click somewhere else, the Chinese characters in the input field of Inspector will get duplicated

    Bug#2

    Step1: create a brand-new Unity project

    Step2: create a build-in Input Field UI

    Step3: run the game

    Step4: type some Chinese characters in the Input Field without hitting Enter

    Step5: click somewhere else, the Chinese characters in the Input Field will get duplicated

    Bug#3

    Step1: create a brand-new Unity project

    Step2: create three build-in Input Field UIs

    Step3: for demonstration sake, download free Chinese font “SourceHanSerifTW-Regular.otf” here (the bug doesn’t depend on the Chinese font the user is using), https://github.com/adobe-fonts/sour...ase/SubsetOTF/TW/SourceHanSerifTW-Regular.otf

    Step4: replace the fonts of the Input Fields, both placeholder and text, with the Chinese font we have just downloaded

    Step5: run the game

    Step6: type some Chinese words in the first Input Field without hitting Enter key

    Step7: hit “Ctrl” + “Space” to be able to type Chinese again

    Step8: select the second Input Field and type some Chinese words in the second Input Field without hitting Enter key

    Step9: click somewhere else, Unity will throw an Invalid Operation Exception error in the console and the texts in the Input Field glitches

    Bug#4
    Step1: after reproducing Bug#1 or Bug#2, we won't be able to type Chinese using Microsoft Bopomofo until we hit "Ctrl"+"Space".

    PS. I actually don't know why we can fix Bug#4 by hitting "Ctrl"+"Space", I found this method by accident.



    Are you having these issues as well?
     
    Last edited: Dec 21, 2018
    jrumps likes this.
  2. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    I have also tested the TextMeshPro's Input Field, it has bug#2 as well, but it seems that it doesn't have bug#3.
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Prior to releasing the next release of the TextMesh Pro package with the new Dynamic SDF system, I wanted to address as many reported issues as possible without incurring too much delays on the release.

    As such I am currently going through the list of reported issues with the TMP Input Field and will take a look at these.

    I haven't tested these myself since I just noticed this post. So to be sure, bug #1 and Bug #2 are also happening in the TMP Input Field. Correct?

    Do you have some video showing Bug #1 and #2?
     
    better_walk_away likes this.
  4. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    I will record a bug reproducing video for TextMeshPro as well, just a moment.
     
    Stephan_B likes this.
  5. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    I have made a video for my bug report to TextMeshPro, it has the same bug#1 and bug#2 that I described here, and the ways to reproduce the bugs are the same as the Unity's.
    I also have committed my testing project to GitHub, here is the link:
    https://github.com/h3902340/TMPChineseBugReport
    For convenience sake, this project has already contained two free Chinese fonts, one is HanaMinA.ttf, the other is SourceHanSerifTW-Regular.otf. And I have also built the font assets in the project, the custom characters file is also included in the project.
    HanaMinA.ttf is available on: https://osdn.net/projects/hanazono-font/releases/68253
    SourceHanSerifTW-Regular.otf is available on: https://github.com/adobe-fonts/sour...ase/SubsetOTF/TW/SourceHanSerifTW-Regular.otf

    If we try both of these fonts, bug#1 and bug#2 are still there, so I can say that it is not because of the font file I am using. Note that we have to use "Microsoft Bopomofo" to type Chinese, and we have to hit "Ctrl" + "Space" to be able to type Chinese again if we insert Chinese word without hitting Enter.

     
    Last edited: Dec 20, 2018
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Thank you for the video. I'll take a closer look at these issues tomorrow.

    How are you entering the text? IME, keyboard, virtual keyboard?

    Out of curiosity, how does Microsoft's virtual keyboard when entering chinese text?

    Quick Tip: I noticed in your video that you navigated to the Placeholder and Text child components to change their point size.

    Since this is something that I was constantly having to do when I first created the TMP Input Field, I added the ability to set the font asset and point size for both of these sub object via the main Input Field inspector as seen in the image below.

    upload_2018-12-20_0-23-3.png
     
  7. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    I was using a keyboard to type Chinese.
    In the video, I typed "你好" as an example.
    After we switch to Microsoft Bopomofo, we type "s"+"u"+"3"+"c"+"l"+"3", this way, we will see that we have inserted "你好" in the textbox. After that, don't hit Enter key, use mouse to click somewhere else, then we should be able to reproduce the duplicated Chinese characters bug.
    And thank you for the tips!
     
    Last edited: Dec 20, 2018
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    When I type the character sequence you indicated, I get difference characters. I get the following "苏此" which is obviously incorrect. Although this should not prevent me from testing the issues you reported, I would like to figure out the correct keyboard / language configuration to get the correct characters.

    Do I have the wrong language pack / keyboard selected?

    upload_2018-12-20_3-44-9.png
     
  9. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Hi, that's not the language pack I was using. The language pack should look like this:
    Untitled-1.png
     
  10. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Search "Taiwan", there is only one search result, that's the language I am using. And in the Keyboards option, choose "Microsoft Bopomofo".
    upload_2018-12-20_20-11-6.png
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    As I am trying to test this, I am running into a strange behavior with this Bopomofo mode where it appears to work (ie. I can type composition strings) but then it stops to work where it is only inputs English characters. Like this mode gets disabled. If I go try to type in Word or in a browser the behavior is correct.

    If I switch to Microsoft Pinyin, I don't have this issue where once in Chinese mode, it remains this way.

    I am curious to know if you are seeing the same behavior as I describe?

    P.S. This appears to be another issue besides those you have reported. That is unless I am doing something wrong.
     
  12. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Yes, I have this issue as well. As I have described in the bug report, once we reproduce this bug, we have to hit "Ctrl"+"Space" to be able to type Chinese using Microsoft Bopomofo again.
    Did you successfully reproduce the duplicated Chinese words bug I mentioned here?
     
  13. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    I am able to reproduce the issue you reported so I'll be focusing on that tomorrow.

    I am also checking internally about the behavior with Bopomofo as this appears to be another issue which I guess we can call #4.
     
  14. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Many thanks. Yes, I should have separated this issue as the bug#4.
     
  15. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Is this CTRL + Space a known functionality to reset the input?
     
  16. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    I actually don't know why we can fix Bug#4 by hitting "Ctrl"+"Space", I found this method by accident...
    Normally, we don’t need to hit “Ctrl”+”Space” after finishing typing Chinese using Microsoft Bopomofo, this bug only happens on Unity.
     
    Last edited: Dec 21, 2018
  17. CashNoc

    CashNoc

    Joined:
    Nov 6, 2013
    Posts:
    4
    Has there been any progress in this bug?
     
  18. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    They said that they are planning to deprecate the current input system and replacing it with a new one. So I assume that this bug will also be fixed.
    We can download the latest input system here:
    https://github.com/Unity-Technologies/InputSystem
     
    CashNoc likes this.
  19. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    Please let me know the outcome of your testing on the new system.

    P.S. I would still like to see this issue resolved in the current / legacy system. I'll check again internally to see if I can get an update on this.
     
    CashNoc likes this.
  20. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    What specific issue are you referencing? The IME issue?
     
  21. CashNoc

    CashNoc

    Joined:
    Nov 6, 2013
    Posts:
    4
    Inputfield still has the same problem in editor mode.
    The event system doesn't seem to respond to the new input system, so I can't test the Inputfield in Run mode
    But I guess it should be the same.
     
  22. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Hi,
    I have tried the new input system, but it seems that it is totally unusable and the Microsoft Bopomofo duplication bug still exists after importing the preview package of the new input system.
    I am using Unity 2018.3.7f1, I have followed the installation guide in the Github repository, I imported the new input system through Package Manager, I changed the "Active Input Handling" option to "Input System (Preview)". After restarting Unity, Unity froze, I couldn't click anything. I had also tried the Input Field, both Unity build-in and TextMeshPro, before I restarted Unity, it doesn't work, I can't even click on the Input Field.
    I have recorded a video to demonstrate all the problems that I encountered:
     
    MrLucid72 likes this.
  23. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    I'll take a look at the video tomorrow and follow up with the team working on the New Input System.

    I'll follow up with you as soon as I have more information.
     
  24. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Unity QA team replied my case email and said that they are making a new input system, they have logged the bugs that I reported in the new input system Github page, my case number is 1110785. So I think the bugs I reported are relevant to the new input system.
     
    Stephan_B likes this.
  25. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    Hi all,
    I was able to workaround Bug#2 through scripting. The duplication glitch happens when isFocused is set to false. So I create a MonoBehaviour script and then store the string value of the Text child under the Input Field in a text buffer when isFocused is set to true. When input field is not being focused, I override the value of the input field's text with the value of the text buffer. This resolved the issue of typing with Bopomofo (Zhuyin) input method in OSX entirely, but in Windows 10, bug#4 still exists. We still need to press "Ctrl" + "Space" if we don't press Enter after typing Chinese with Microsoft Bopomofo.

    In my bug report, I had only mentioned the Bopomofo input bug in Windows 10, However, I later found that there was also a bug regarding typing Chinese in OSX as well. The Bopomofo input method in OSX is called "Zhuyin", if we use Zhuyin to type Chinese in Unity Edtior or the game that is built with Unity, the Chinese characters will disappear after hitting Enter, we simply cannot type Chinese in Unity, we have to type somewhere and then paste it in.

    I have successfully addressed the Zhuyin input method bug in OSX by myself, and the bug#2 in Windows 10 also has been addressed. But I couldn't find a way to fix Bug#4. I also found that in some unclear scenarios, we cannot even enable Chinese input again by pressing "CTRL"+"SPACE". I later found that we can enable Chinese input again by opening the command prompt as Administrator and then type the following command: schtasks /Run /TN \Microsoft\Windows\TextServicesFramework\MsCtfMonitor

    I am looking forward to the official fix to this bug.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3.  
    4. public class InputFieldBopomofoFix:MonoBehaviour
    5. {
    6.     InputField inputField;
    7.     Text text;
    8.     string textBuffer;
    9.     private void Awake()
    10.     {
    11.         if (GetComponent<InputField>() != null)
    12.         {
    13.             inputField = GetComponent<InputField>();
    14.             text = transform.GetChild(1).GetComponent<Text>();
    15.         }
    16.         else
    17.         {
    18.             Debug.LogError("There is no Input Field attached on this game object.");
    19.         }
    20.     }
    21.     bool isSelected=false;
    22.     private void Update()
    23.     {
    24.         if (inputField.isFocused)
    25.             isSelected = true;
    26.         if (isSelected)
    27.         {
    28.             if (inputField.isFocused)
    29.             {
    30.                 textBuffer = text.text;
    31.             }
    32.             else
    33.             {
    34.                 inputField.text = textBuffer;
    35.                 isSelected = false;
    36.             }
    37.         }
    38.     }
    39. }
     
  26. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    These issues are all related to mishandling of IME input in Unity itself. Based on my research, this issue has been present since Unity 5.6 or possibly earlier.

    The root of these issues is with the handling of IME where it is disabled when a text field loses focus (which is correct) but never re-enabled when an input field regains focus.

    This enabling / disabling of IME was added because Unity being a game engine where users are likely to use the keyboard to interact with a game such as using keys like ASDW to move around, you don't want the IME to remain active unless a text field is focused. So the disabling part works but not the re-enabling part. This issue affect overall IME functionality in Unity which indirectly affects IMGUI, UGUI and TMP. Ie. anything using input.

    The input sequence duplication is related to this as well.
     
  27. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    It has been 6 months since I reported these bugs to Unity, there still isn’t any sign of these issues being fixed.
    My game uses only mouse to control everything, and uses keyboard only when typing on InputField.
    My game is pure Chinese, both Unity Editor and in-game InputField are having these bugs, they cause huge pain when typing Chinese in Unity.
    Hope that the new input system will fix these issues somehow.
     
    Last edited: Jul 5, 2019
    MrLucid72 likes this.
  28. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    1,008
  29. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    291
    MrLucid72 likes this.
  30. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    1,008
    If they ate their own dogfood like Unreal does, we wouldn't have this issue. They don't make games because they know they'd have more bugs to fix than any backlogged and iceboxes features combined.

    It's not enough that Unity is now infamous for its instability. I wonder how many bugs need to accumulate until bug fixes are unavoidable?
     
    Last edited: Aug 31, 2022