Author Topic: Japanese Input Broken on Desktop?  (Read 7551 times)

thefudster

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Japanese Input Broken on Desktop?
« on: February 04, 2014, 01:30:06 PM »
I'm having problems with Japanese input support on Mac. I modified the UILabel in the example scene showing an input box. I changed it to a dynamic font with Japanese support. However, the text box fails to accept my Japanese input properly.

I made a video demonstrating the problem:
http://www.youtube.com/watch?v=-kz6E8NI3r4&feature=youtu.be

Basically when I press enter to 'commit' my Chinese character selection it deletes the Japanese part and keeps the romanji(english characters).

Anyone else seen this problem?
« Last Edit: February 04, 2014, 07:09:11 PM by thefudster »

thefudster

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Japanese Input Broken on Desktop?
« Reply #1 on: February 05, 2014, 02:57:34 PM »
bump

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Japanese Input Broken on Desktop?
« Reply #2 on: February 05, 2014, 03:01:29 PM »
Hmm. IME got broken? I'll have a look, thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Japanese Input Broken on Desktop?
« Reply #3 on: February 05, 2014, 08:39:57 PM »
I am guessing there is a difference between how IME works on windows and how it works on the Mac? When I try it, everything works as you described it should. I type "taberu", I get the dialog, I hit space to accept, enter to move past what I typed and start typing again. It's different from how simplified Chinese seems to work. There I don't need to hit Enter. I just type "ni", space, "hao", space.

I did notice two other issues while I was digging through the code though. First, the IME composition box is not positioned properly. Second, what you type with IME enabled doesn't actually show up unless there is text present. I will fix both and see if I can repro this on my mac.

Edit: Can you double check something for me? UIInput.Update function, do this:

  1.                         if (!string.IsNullOrEmpty(s))
  2.                         {
  3.                                 Debug.Log(s); // <-- this right here
  4.  
  5.                                 for (int i = 0; i < s.Length; ++i)
  6.                                 {
  7.                                         char ch = s[i];
  8.                                         if (ch >= ' ') Insert(ch.ToString());
  9.                                 }
  10.                         }
See if you get the Debug.Logs while typing. In my case, on Win 8, I do not get anything until I actually hit Enter.

If you do get it, try changing the "if" to:
  1. if (string.IsNullOrEmpty(Input.compositionString) && !string.IsNullOrEmpty(Input.inputString))
« Last Edit: February 05, 2014, 08:49:01 PM by ArenMook »

thefudster

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Japanese Input Broken on Desktop?
« Reply #4 on: February 06, 2014, 05:08:16 AM »
The function appears to receive each letter one by one. So it logs:
t
a
b
e
r
u

Then when I hit space it gets nothing and enter again it appears to get nothing.

I changed the if statement to what you mentioned. It didn't get anything when I hit space and then it logged a string containing only a '\n' after I hit enter.

Interesting note: http://docs.unity3d.com/Documentation/Manual/IMEInput.html
"IME on Unity is not supported on mac webplayers at the moment."

I also exported a mac desktop build to test and make sure the behavior was the same as in the editor and it is. I did not export it to web player yet but of course the docs say it's not even supported... Just checked it out in web player even though unity says it doesn't support it. The weird thing is it worked! I couldn't see anything as I was typing and the IME composition box isn't visible but if I do the keystrokes the input does actually work and 食べる appears like it should.
« Last Edit: February 06, 2014, 05:27:51 AM by thefudster »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Japanese Input Broken on Desktop?
« Reply #5 on: February 06, 2014, 10:01:40 PM »
So it seems it's a bug in Unity related to different handling of Input.inputString on OSX, and different again in how it's in the web player. I would suggest reporting this bug to Unity to address properly.

Input.inputString is always clear while using IME in Windows, until you actually hit Enter, which is what you'd expect. Instead Input.compositionString has the data while typing.