Saturday, March 31, 2018

How to use Urdu/Arabic language in Unity 3D using Unicode Standard?

As we know that computers just deal with numbers therefore they store characters and alphabets by assigning a number for each one.The Unicode Standard provides a unique number for every character no matter what language.Here is the unicode representation of few urdu characters.


See links for complete set of Unicodes of Urdu and Arabic language.
1- http://tabish.freeshell.org/u-font/chart.html
2- https://unicode-table.com/en/#arabic
3- https://en.wikipedia.org/wiki/Arabic_script_in_Unicode

Now let see how to use these unicodes in Unity 3D. To create Urdu word "Tamater"(Tomato in english) by using unicodes of Urdu alphabets Tey,Meem,Alif and Rey follow below steps

1-  Create Text GameObject by GameObject > UI > Text. Use font of your choice I'm using
     "ADOBEARABIC- REGULAR".
2-  Create C# script "UrduWord" and attach with Text GameObject.
3-  Paste the code given below.
   
    Text wordTxt;    
    void Start ()
    {
        wordTxt = GetComponent<Text>();
        MyWord();
    }

    public void MyWord ()
    {
       char tey = '\uFB68';   //tey unicode
       char meem = '\uFEE3';  //meem unicode
       char alif = '\uFE8E';  //alif unicode 
       char tey2 = '\uFB68'
       char rey = '\uFEAE';
    
        wordTxt.text = rey.ToString() + tey2.ToString() + 
                       alif.ToString () + meem.ToString() +
                       tey.ToString();
   
            


4- Hit the play button and you will see output like this



As it is very difficult to add Unicodes every time you want to create new word therefore I've created a text file containing Unicodes of all Urdu alphabets in sequence. Read this file sequentially and create a Dictionary for reusability.
https://www.mediafire.com/file/jkof6mjjxbtk50y/UrduAlphabets.txt

2 comments:

  1. Have a look at https://youtu.be/MWpmzeB3U4Y , it shows how to Type Urdu using Urdu Nigar Rray version in Unity3D https://youtu.be/MWpmzeB3U4Y

    ReplyDelete

Changing Build Setting Dynamically/Programmatically in Unity 3D

Suppose we are publishing app on three platforms Google Play, iTunes Connect and Amazon. For every single change we have to make a separate ...