Untiy的阿拉伯文本適配

Unity Text的文本是左往右讀,阿拉伯文的文本是右往左讀。在複製粘貼之後,可能文本順序會發生改變。並且通過不Text組件的自動換行的時候會造成換行位置的不正確。在做阿拉伯UI時候需要引入插件處理

Unity商店裏面有兩個關於阿拉伯語言適配的免費插件:

Arabic Support for Unity
Arabic lines support


Arabic Support for Unity

This plugin allows you to use accurate and correct Arabic text in your game or 3D application. Supports Tashkeel and Hindu numbers. Supports multiple lines. Very easy with Text Mesh Pro. Supports 4 Persian Characters. The project is open sourced here: https://github.com/Konash/arabic-support-unity

可以用來校驗或者修復阿拉伯文本的文字順序,並返回其正確的語序。

使用時候需要引入命名空間

using ArabicSupport;

可以通過

public static string Fix(string str, bool showTashkeel, bool useHinduNumbers)

來對文本進行校驗。校驗後的文本將會變成從右外左的閱讀順序的阿拉伯語言文本。


Arabic lines support

what is this ?
a script to help you to show Arabic text in right way
what it do ?
fixes the arrange of lines in Arabic texts
How to Use ?
- you must download and import Arabic Support for Unity from here
- download and import this package
- add textFixer script to you Text UI game object
-write or copy paste your text to enter text field
- run ant it will fix the lines
please take a look into the sample scene to have a better understanding of this script

用來給多行的阿拉伯文進行修正。之前提到過阿拉伯文字是右往左讀的語言,如果直接適應Unity的自動換行,因爲語序問題。阿拉伯文的文末將會變成最頂部的一行,而首部則會變成文本的後段。

Arabic lines support 是基於Arabic Support for Unity的多段阿拉伯文的修正插件

給文本框加上TextFixer,並且在EnterText輸入阿拉伯文本,那在這個組件Start()的時候將會調用其方法進行換行的修正。
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章