在输入字段中编写RTL [英] Writing RTL in input field

查看:176
本文介绍了在输入字段中编写RTL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在统一输入字段中写波斯语.波斯语是从右到左的语言,它的字母类似于阿拉伯语.

I'm trying to write Persian in unity input fields. Persian is right to left language and it's alphabet is similar to Arabic.

我找到了一个,该库可以转换和更正文本.很好.当我将转换后的文本显示为Debug.Log()时,一切都是完美的,但问题是当我要将校正后的文本放入输入字段时,它将被反转!我试图反转输入字段的文本,但是什么也没发生!

I've found a library that converts and corrects the text. It's works just fine. When I'm showing the converted text into Debug.Log() everything is perfect but the problem is when I'm going to put corrected text into input field it would be reversed! I've tried to reversed the input field text but nothing happened!

这是我的代码

 public InputField empName;

 PersianMaker pm;
 string tempStr = "";

 private void Start()
 {
     pm = new PersianMaker();
 }

 void OnGUI()
 {
     tempStr = "";

     if (!string.IsNullOrEmpty(empName.text))
     {
         tempStr = pm.ToPersian(empName.text);
         tempStr = Regex.Replace(tempStr, @"\s+", " ");
         tempStr = tempStr.Trim();
         //empName.text = ReverseString(empName.text);
         //empName.text = tempStr;
         Debug.Log(tempStr);
     }
 }

 private string ReverseString(string s)
 {
     char[] arr = s.ToCharArray();
     Array.Reverse(arr);
     return new string(arr);
 }

有什么建议吗?

推荐答案

您可以使用以下名为 UPersian

它运作良好,我认为这是目前唯一可用的解决方案.

It works well and I think this is the only solution available out there.

这篇关于在输入字段中编写RTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆