RTL Text Mesh Pro

repository·master·Indexed 20 days ago

https://github.com/pnarimani/rtltmpro

A Unity plugin that adds Right-to-Left (RTL) language support for Arabic, Farsi, and Hebrew to the standard TextMeshPro plugin. It provides realtime RTL text conversion, support for rich text tags, and RTL-compatible InputFields and Dropdowns.

Tokens
830
Snippets
1
Records
6
Agent score
22%

What's inside RTL Text Mesh Pro

  1. Install RTL Text Mesh Pro via Unity Package Manager

    master

    The recommended way to install RTL Text Mesh Pro is via the Unity Package Manager (UPM) using a Git URL. This ensures you get a stable version.

    Prerequisite: You must have the TextMeshPro plugin installed in your project via the Unity Package Manager. DO NOT install TextMeshPro from the Asset Store.

    Steps to install via Git URL:

    1. Open the Unity Package Manager in the Unity Editor.
    2. Click the + (add) button.
    3. Select Add package from git URL....
    4. Enter the following URL: https://github.com/hk1ll3r/RTLTMPro.git?path=/UPMPackage
    5. Click Install.
    https://github.com/hk1ll3r/RTLTMPro.git?path=/UPMPackage
  2. Install RTL Text Mesh Pro via .unitypackage

    master

    For a manual installation that includes both scripts and demo resources (fonts, shaders, scenes) directly into your Assets folder:

    1. Download the latest .unitypackage from the releases section.
    2. In Unity, go to Assets -> Import Package -> Custom Package....
    3. Select the downloaded file and import it.

    Note: For optimized production builds, it is recommended to remove the demo resources after setup.

  3. How to create Font Assets for RTL support

    master

    To use Arabic, Farsi, or Hebrew, you must create a TextMeshPro Font Asset that includes the necessary character ranges.

    1. Open Window > TextMeshPro > Font Asset Creator.
    2. Assign your font file to the Font Source field.
    3. Set the Atlas Size (Recommended: 512x512 for Arabic, 128x128 for Hebrew).
    4. Set Character Set to Unicode Range.
    5. Copy the character ranges from the files located in Assets/RTLTMPro/Ranges into the Character Sequence (Hex) field:
      • For all Arabic characters: Use ArabicAll.txt.
      • For Arabic letters: Use ArabicLetters.txt.
      • For Arabic digits: Use ArabicDigits.txt.
      • For Arabic tashkeel: Use ArabicTashkeel.txt.
      • For Hebrew letters: Use HebrewLetters.txt.
    6. Click Generate Font Atlas.
    7. Click Save TextMeshPro Font Asset.
  4. Use RTL Text Mesh Pro components in Unity

    master

    Once installed, you can use RTL-compatible UI elements in your scene.

    Creating RTL UI elements:

    • Use the menu GameObject > UI/ - RTLTMP* to create new RTL-enabled UI objects.
    • Alternatively, replace existing TextMeshPro UGUI components with RTL Text Mesh Pro components.

    Configuration:

    1. Assign your generated font asset to the Font Asset property in the RTL Text Mesh Pro component.
    2. Enter your text in the RTL TEXT INPUT BOX section.
  5. Install RTL Text Mesh Pro via OpenUPM

    master

    You can also install the package using OpenUPM by adding it as a scoped registry.

    1. In Unity, go to Project Settings.
    2. Add https://package.openupm.com as a scoped registry.
    3. Open the Package Manager window.
    4. Change the scope to My Registries.
    5. Select RTL Text Mesh Pro and click Install.
  6. Configure RTL Text Mesh Pro component options

    master

    The RTL Text Mesh Pro component provides several options to control text rendering behavior:

    OptionDescription
    FarsiWhen checked, English numbers are converted to Farsi numbers. When unchecked, they are converted to Arabic numbers.
    Preserve NumbersWhen checked, numbers will not be converted.
    Force FixForces the component to fix text even if it starts with English characters. Warning: Multiline English texts may have issues when this is checked.
    Fix TagsWhen checked, the plugin attempts to fix rich text tags.