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
  3. Dismiss Notice

Need assistance on Chinese GUI development

Discussion in 'Immediate Mode GUI (IMGUI)' started by Sam Lin, Jan 28, 2008.

  1. Sam Lin

    Sam Lin

    Joined:
    Jan 28, 2008
    Posts:
    11
    We are newly on Unity and trying to develop Chinese GUI.

    Though we are able to make Chinese character display on GUI.Text and display on Console, however, we are yet able to make Chinese character display on some important GUI Class components such as GUI.Box, GUI.Button, and GUI.Label.

    Any help is appreciated.

    Sam
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Are you using a font that supports chinese letters?

    You will want to Create a new gui skin and assign a font that supports chinese letters to default Font. Then add:

    function OnGUI ()
    {
    GUI.skin = theSkin;
    ....
     
  3. tsphillips

    tsphillips

    Joined:
    Jan 9, 2006
    Posts:
    359
    The default Unity editor, Unitron, does not seem to support UTF-8; using the Unitron editor and the OnGUI() method does not work for Chinese. I don't know if the Mac OS X console supports UTF-8. In general, though, I have always had problems with editors and shells displaying non-Latin characters.

    A GUIText object will work for Chinese. I tried an example using the LiSong Pro font. Just make sure that both the Font and Material attributes are set for the GUIText object.

    I am very interested in multi-lingual applications, especially in Chinese. I would certainly be willing to help with any issues that come up when deploying for Chinese. I can be reached by email at thomas.phillips <at> benxing.com.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It should; go to the Open Save preferences and set the encoding there. I've used some non-ASCII characters with Unitron and it works.

    --Eric
     
  5. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    I've been playing around with CJK fonts in Unity for the last 6 months and there are really just 2 key problems that I've not been able to solve.
    Firstly, the amount of memory consumed by the typefaces when using all 3 characters sets is huge - I think the typical Chinese JianTi and FanTi are around 8Mb each, add an extra weight and things start getting out of hand. Korean and Japanese are a bit smaller, but supporting all Asian fonts explodes anything that runs over web.
    Secondly, the IME - I haven't had much luck getting that to work - which is really the biggest show stopper. The main problem seems to be where the IME needs to display the character palette, which doesn't work too well in a 3D engine. Phonetic scripts won't be a problem (Hangul, Hiragana Katakana), but their semantic cousins absolutely need this. I guess Blizzard has already solved this in WoW, would be nice to know how.
    Cheers
    Shaun
     
  6. nafonso

    nafonso

    Joined:
    Aug 10, 2006
    Posts:
    377
    I don't know why, I found out after sending a bug report, but if you use C# you must save files in UTF-16. I don't understand why this happens, maybe it's something "crazy" about .NET string classes or something....

    Also, if I hardcode something, it appears correctly on the GUI (e.g. a button or a label), but I can't input text that uses accents (e.g. á à ã â é õ) in the GUI text field. Does anyone (latin users?) have the problem?

    Regards,
    Afonso
     
  7. Sam Lin

    Sam Lin

    Joined:
    Jan 28, 2008
    Posts:
    11
    Thanks for all replies.

    We are successfully create a GUI skin and assigned a Chinese font set as default font.

    We also successfully make Chinese font display on button, text field, text area, box and label. Please look attached pictures.

    However, there are some pending issues:

    1、We can switch different Chinese input methods on Mac environment, but not able to display on screen properly. They were scrambled. On the other hand, we not able to switch input methods on Windows environment, but display correctly.

    2. The published Unity document size is extremely big. There are about extra 4MB than usual w/o Chinese character Unity document. (As in this document, it should only few hundreds kbytes w/o Chinese characters.) We suspect contain either all Chinese fonts (although we just input few characters), or , the document contains big character field texture.

    Who can give a hand?
     

    Attached Files:

  8. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    Sam, please see my post before.

    When you use a semantic character set, Unity writes all possible characters out to a huge texture.

    As for the input methods, what do you mean, the text was scrambled on Mac?
     
  9. tsphillips

    tsphillips

    Joined:
    Jan 9, 2006
    Posts:
    359
    I didn't think to look there -- that did the trick. Thanks!

    Like Shaun wrote, the font gets turned into a very large texture. When importing an entire font, all the characters have to be drawn out into one giant image. If you are displaying a finite number of strings, however, you could use a trick from localization. First, you determine all possible strings that can be displayed. Second, you assign each string a number. Third, you pre-render each string using something like Photoshop. (There are a number of variations on this technique.)

    If you have every possible string pre-rendered to images, then you can load those images separately (like a GUITexture), or you can compile them all into a single texture. (Like a texture atlas, but for strings.)

    Will pre-rendering all strings save space? That depends on how many you have, compared to the whole font size. Depending on how and when the strings are presented to the user, you might also consider streaming in separate images (using the streamable web player).
     
  10. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    What could be easier is to modify a TTF file and delete the characters you won't need. Then when you import it into Unity, it will only draw the available characters into the texture.
     
  11. Sam Lin

    Sam Lin

    Joined:
    Jan 28, 2008
    Posts:
    11
    Dear Shuan and Tom,

    We made some experimentations today while you provide more valuable inputs:

    1. We changed another Chinese font set and set it to maximum 13 point size. This made whole font size reduce to just little more than 1MB, compare with original typical font set at about 4MB. We found if we extend to 14 points, then the font size almost doubled.

    2. Then, we also implemented exactly as what Tom suggested, took Photoshop to make font image, but not string by string. We input all needed strings on one image. With this way, this image can further reduced to less than 200KB, depending on how many font strings needed on this image.

    However, this wont be an idea solution. This way can only support pre-progammed Unity document, not for end user to interactive input on their computer. Secondary, such approach not an idea Chinese application.

    Therefore, the ultimate solution still need Unity to put proper resources. I think China (Simplified Chinese) and Taiwan (Traditional Chinese) are sizable enough market deserve for Unity to cultivate.

    We are more than happy to be pilot test partner for Unity.

    Sam
     
  12. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    Sam, how was the quality at this point size? I'm curious if high stroke characters were easy to read (especially for 繁体字). Also, are you sure all characters were included in the texture? 1Mb sounds a little too small, but maybe with compression it's possible.
     
  13. Sam Lin

    Sam Lin

    Joined:
    Jan 28, 2008
    Posts:
    11
    Shuan, my mistake. The font size we put is 14pts instead of 13pts, but remains about >1MB size. The font we selected is FangZheng Song Ti. The quality looks acceptable but not nice enough. It includes full normal Simplified Chinese characters, about > 4,000 characters.

    I yet test Traditional Chinese.

    Sam
    in Macau Airport, on the way from Beijing to Taipei.
     
  14. dongke

    dongke

    Joined:
    Apr 17, 2008
    Posts:
    93
    Hi can you please attach this example above?

    chinese charactor display GUI

    thankyou
     
  15. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    If you want to get full unicode support Unity, it's very simple.
    1. Go to any windows computer that has "Support for East Asian Languages" turned on in control panel->regional settings and find a file called ARIALUNI.TTF (it lives in windows\fonts)
    2. Copy it into you Unity Assets folder
    3. Select the ARIALUNI asset and click settings
    4. Turn on "Unicode" in the characters dropdown
    5. Assign the font to a GUISkin as the default

    Now whatever characters you use in Unity will just work. The texture will be very large and can be reduced by adjusting the font size. I use 14 which gives me a 16Mb texture.

    It's not the best solution for webplayer content, but it's the only choice for supporting every language right now.
     
  16. lgoss007

    lgoss007

    Joined:
    Dec 6, 2006
    Posts:
    88
    Well I don't know what the plans are for Unity, but I know in my work with OSG (OpenSceneGraph) they have a pretty nice solution there for supporting fonts (not web apps) which would be nice. OSG loads fonts on the fly from TTF's, but converts the TTF's to textures at runtime and then caches them. This way you don't have to mess around with cutting down font files. I think it would be nice to have something like that in Unity.

    Lucas
     
  17. nafonso

    nafonso

    Joined:
    Aug 10, 2006
    Posts:
    377
    Any word on when characters that require multiple inputs (I've seen people referring to them as IME), like á à ã â ó é will be supported in text fields? Or is this completely out of UTs radar?

    Regards,
    Afonso
     
  18. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    391
    Shaun have you gotten Hiragan or katakan input to work on Unity and Mac? or Hangual? I have not been able to. I can get it to display kanji and kana including in text fields but all input appears in latin.
     
  19. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    I've done some testing since that comment and found that Hangul doesn't work, which I should've realized before, as even though it's phonetic it still has cell based composition for the consonants and vowels. I've not tested Hirigana or Katakana yet, but it sounds like they suffer the same problem. It's just a case of overhauling Unity's text input to work with the system font's and IME more directly - which Unity knows about and is working on - but no deliverable date yet.
     
  20. Harry Tuttle

    Harry Tuttle

    Joined:
    Jan 3, 2006
    Posts:
    122
    How did you manage to import the arial unicode font nicely?

    All I get is a horrible fuzzy mess (see attachment)
     

    Attached Files:

  21. wuwu

    wuwu

    Joined:
    Jun 17, 2008
    Posts:
    72
    i have tried to do this followed it for some reason my font wont come up..

    its a myriad pro and im trying to use

    ı ö ü ğ but on gui box it just wont show up :)

    thanks
     
  22. wuwu

    wuwu

    Joined:
    Jun 17, 2008
    Posts:
    72
    oops ignore my comment it works :)