Unity Editor中的印地语字母

时间:2016-07-20 07:42:32

标签: c# unity3d

我正在制作印地语字母排序游戏,我创建了一个包含少量单词的数组,然后我创建了一个用于制作该单词的字母数组。 我试图将此字符串放在统一编辑器的文本组件上,但它在一台PC上接受此字符串,而在另一台PC上忽略它

    private string[] questions = {"टप","टब","वक","कप","रख","पर","खत","भर","दस","एक","धन","ईख","हल","फल","जल","जग","वन","नट","पथ","नथ","रथ","बस","घर","छत","उठ","ठग","ऊन","धम","नभ","जप","तट","कद","थक","दक","औस"};
    private string[] characters = { "ट", "प", "ब", "व", "क", "र", "ख", "भ", "द", "स", "ए", "ध", "न", "ई", "ह", "ल", "फ़", "ज", "ग", "थ", "छ", "त","ठ", "ऊं", "म", "औ"}; 
   void NextLevel(string question)
    {
        int temp_1, temp_2, temp_3, temp_4;
        missing = question.Substring(0, 1);
        missing1 = question.Substring(1, 1);
        print(question);
        do
        {
            random_1 = Random.Range(0, 25);
        }
        while (characters[random_1].Equals(missing) || characters[random_1].Equals(missing));
        temp_1 = random_1 / 7;
        if (temp_1 == 0)
            Top_Left_Text.text = missing;
        if (temp_1 == 1)
            Top_Right_Text.text = missing;
        if (temp_1 == 2)
            Bottom_Left_Text.text = missing;
        if (temp_1 == 3)
            Bottom_Right_Text.text = missing;
        temp_2 = temp_1;
        do
        {
            random_2 = Random.Range(0, 25);
            temp_2 = random_2 / 7;
        } while (temp_2.Equals(temp_1) || characters[random_2].Equals(missing) || characters[random_2].Equals(missing1) || (temp_2 * 7 / 9).Equals(checkprevrandom));
        if (temp_2 == 0)
            Top_Left_Text.text = missing1;
        if (temp_2 == 1)
            Top_Right_Text.text = missing1;
        if (temp_2 == 2)
            Bottom_Left_Text.text = missing1;
        if (temp_2 == 3)
            Bottom_Right_Text.text = missing1;
        temp_3 = temp_2;
        do
        {
            random_3 = Random.Range(0, 25);
            temp_3 = random_3 / 7;
        } while (temp_3.Equals(temp_2) || temp_3.Equals(temp_1) || characters[random_3].Equals(missing) || characters[random_3].Equals(missing1));
        temp_4 = temp_3;
        do
        {
            random_4 = Random.Range(0, 25);
            temp_4 = random_4 / 7;
        } while (temp_4.Equals(temp_3) || temp_4.Equals(temp_2) || temp_4.Equals(temp_1) || characters[random_4].Equals(missing) || characters[random_4].Equals(missing1));
        checkprevrandom = temp_2 * 7 / 9;
        Bottom_Right.GetComponent<SpriteRenderer>().sprite = letters[temp_2];
        Bottom_Right.GetComponent<SpriteRenderer>().color = colorChoice[Random.Range(0, colorChoice.Length)];
        Bottom_Left.GetComponent<SpriteRenderer>().sprite = letters[temp_1];
        Bottom_Left.GetComponent<SpriteRenderer>().color = colorChoice[Random.Range(0, colorChoice.Length)];
        Top_Right.GetComponent<SpriteRenderer>().sprite = letters[temp_3];
        Top_Right.GetComponent<SpriteRenderer>().color = colorChoice[Random.Range(0, colorChoice.Length)];
        Top_Left.GetComponent<SpriteRenderer>().sprite = letters[temp_4];
        Top_Left.GetComponent<SpriteRenderer>().color = colorChoice[Random.Range(0, colorChoice.Length)];
        Letter_Answer_1.GetComponent<SpriteRenderer>().sprite = letters[temp_4];
        Letter_Answer_2.GetComponent<SpriteRenderer>().sprite = letters[temp_2];
        if (temp_1 != 0 && temp_2 != 0)
            Top_Left_Text.text = characters[random_1];
        if (temp_1 != 1 && temp_2 != 1)
            Top_Right_Text.text = characters[random_2];
        if (temp_1 != 2 && temp_2 != 2)
            Bottom_Left_Text.text = characters[random_3];
        if (temp_1 != 3 && temp_2 != 3)
            Bottom_Right_Text.text = characters[random_4];
    }

1 个答案:

答案 0 :(得分:0)

Unity UI Text支持unicode,但它不支持全范围的unicode。您可以使用以下扩展本机文本元素的代码来使用unicode:

Unity Text UTF32 Extension

然后你至少可以直接显示\uf204这样的unicode字母(只是一个用法例子)

相关问题