Writing RTL in input field

。_饼干妹妹 提交于 2019-12-08 03:04:23

问题


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

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!

Here's my code

 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);
 }

Any suggestion?


回答1:


You could use the following open source library called UPersian

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



来源:https://stackoverflow.com/questions/39427741/writing-rtl-in-input-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!