RTL helper system is a Unity package that helps you to manage RTL (Right To Left) in the UI. This system is for addition to localization systems with languages that are written from right to left.
This package used Arabic Letters Support For Unity. For automatic line drop, you need to use TMP insted of regular Unity's text component.
You can bring it to your project in three different ways: downloading this repository, adding it to your project's Package Manager manifest, or through the Package Manager window.
Download or clone this repository into your project in the folder Packages/com.DrimiaInteractive.RTL-helper-system
.
Git must be installed and added to your path.
The following line needs to be added to your Packages/manifest.json
file in your Unity Project under the dependencies
section:
"com.drimiainteractive.rtl-helper-system": "https://github.com/Drimia-Interactive/RTL-helper-system.git"
From Unity 2019.3 we can install packages from git Just add the following URL according to the manual:
https://github.com/Drimia-Interactive/RTL-helper-system.git
we have several components that you can use
- Text Rtl Helper - add this to gameobject with a regular Text component
- Text Mesh Pro Rtl Helper - add this to gameobject with a TMP Text component
- RectTransform Rtl Helper - add this to gameobject with a RectTransform component
- RectTransform With Children Rtl Helper - add this to gameobject with a RectTransform component that you wish to convert RTL to it and all of it children gameobjects.
for the two Text component you can choose to change the text automaticly with the change of RTL or by using the function OnTextChanged
To make all the UI move between Left to Right, you just need to change one boolean.
RtlHelperSystemManager.Instance.isRightToLeft
For example, with using Unity's Localization package:
using DrimiaInteractive.RtlHelperSystem;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
public class ChangeRtl : MonoBehaviour
{
private void Start()
{
LocalizationSettings.SelectedLocaleChanged += LocalizationSettings_SelectedLocaleChanged;
}
private void LocalizationSettings_SelectedLocaleChanged(Locale locale)
{
RtlHelperSystemManager.Instance.isRightToLeft = locale.Identifier.CultureInfo.TextInfo.IsRightToLeft;
}
}