- Home /
Does Unity support UTF-8 string/text?
All string/text in our project are in UTF-8 format. Some string should be displayed in GUI. The online document says Unity support ttf font file and Unicode(UTF-16), can it support UTF-8. If not, is there any work can be done?
I am evaluating Unity3D, for whether it is suitable for Web MMORPG game. We are in China, our game should support all east asian lanuages.
BTW. We have our own game server, written in C++, we will use .net socket directly and use our own byte stream protocol. All text in server side and DB are in UTF-8.
Answer by duck · Apr 29, 2010 at 10:38 AM
Yes, it does.
I have used UTF-8 files as text assets in Unity, and (providing you have embedded a Unicode font), it displays the characters properly.
Answer by Ray-Pendergraph · Apr 29, 2010 at 02:08 PM
The Mono (.NET) character is a unicode character. C# strings (for instance) are strings of unicode characters regardless of the source they were read from, including a UTF-8 source. So like Duck said it just works if it's in the font. The gotcha for you may be that Unity only supports left-to-right languages out of the box. This was a big thing we ran into looking into implementing some text in some Persian languages. So depending on the language, this might affect you.
Yes, C# string is in Unicode and it is very convenient to convert it to/from utf-8. So in client side, we will use C# and unicode; and in server side, we will use utf-8. We only support left-to-right lanuages:)
Answer by Eric5h5 · Apr 29, 2010 at 04:54 PM
One problem with supporting all Asian languages is that fonts in Unity must be pre-rendered to a texture. This can limit fonts to an unreadably small size since all characters must fit in a 2048x2048 texture. This can be alleviated somewhat if you decide to leave out support for older cards and Intel GMA chips, and use a 4096x4096 texture.
Edit: note that this answer only applies to Unity 2.6 and earlier. Unity 3.0 uses dynamic font rendering.
Yes, the codepoint number/font texture size for East Asian font is a problem. 2048 x 2048 is the size almost all video card can support.
I suggest Unity uses such solution, Use a dynamic font texture with small size(for example, 512 x 512), the texture just hold codepoints which are being displayed. Some FIFO algorithm can be used.
Answer by bnmindstorm · Jun 29, 2012 at 11:38 AM
We did create a package that supports asiatic fonts by rendering them directly as text mesh and thus not using Textures to store the font. If you think you may be interested by this package, have a look at our website : http://ttftext.computerdreams.org/
Answer by ND · Sep 12, 2012 at 09:51 PM
Support of right to left Arabic/ Persian / Kurdi right to left unicode in GUI:
Your answer
Follow this Question
Related Questions
Render text/font string to Texture2D 0 Answers
UTF-8 Support in Unity iPhone 1.6? 2 Answers
Using device system fonts for text rendering? 0 Answers
How to implement colored emojis in TMPro? 0 Answers
I want pixelated unicode text. Need suggestions... 2 Answers