问题
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