Implementation Steps with Unity3DFarsi
In Unity, RTL (Right-to-Left) text is not supported by default and requires additional code or a Unity package to function properly.
Unity3DFarsi provides an alternative method to enable Right-to-Left (RTL) writing systems within your Unity project, specifically designed for Arabic and Farsi (Persian) languages.
https://github.com/Spitmaan/Unity3DFarsi
Implementation
Add the Unity Package:
Download the Unity Package from: https://github.com/Spitmaan/Unity3DFarsi
Go to "Assets -> Import Package -> Custom Package". Then select the ARwayKit SDK .unitypackage.
In the "Import Unity Package" window and click "Import" on the bottom right.
A pop-up will appear for the precompiled assemblies, click "Yes" to update them for the changed Unity API:
Assets/AssetStoreTools/Editor/AssetStoreTools.dll
Assets/AssetStoreTools/Editor/AssetStoreToolsExtra.dll
Wait for the scripts to finish compilation.
The in the file Assets/Scripts/SampleFa.cs, change line 26,
public GUIText gTEXT;
topublic Text gTEXT;
Then change line 33 from
gTEXT = GameObject.Find("GUI Text").GetComponent<GUIText> ();
togTEXT = GameObject.Find("GUI Text").GetComponent<Text> ();
Create a New Script for RTL Conversion:
Navigate to
Assets\ARWay\ViewerMode\2_Scripts\
in your Unity project.Create a new C# script file named
MakeRTL.cs
and add the following content:
Attach the Script to a GameObject:
In the
Dashboard-SDK
andARMapSession
scenes, open the folderAssets\ARWay\ViewerMode\0_Scene\
.Create a new empty GameObject.
Select the new GameObject and click the "Add Component" button in the Inspector tab.
Search "Make RTL", and select it from the list.
Set the Locale to Arabic:
Open the file
Assets\ARWay\ViewerMode\2_Scripts\Localization\LocalizeManager.cs
.Modify the function at line 34 as follows:
Add Arabic Text to Selected Objects:
Next, select the text objects in your scene and input the Arabic or Farsi text accordingly.
Replace the Project Font with a Font that Supports RTL Text
The fonts used in the project can be found in the folder Assets\ARWay\ViewerMode\3_Assets\Fonts\
.TTF Fonts
The following .ttf files need to be replaced:
Poppins-Bold.ttf
Poppins-Light.ttf
Poppins-Medium.ttf
Poppins-Regular.ttf
Poppins-SemiBold.ttf
Using your new selected font family, rename the files to match the above and upload them to the folder replacing the existing files.
.ASSET Files
The same needs to be done to the following .asset files:
Poppins Floor.asset
Poppins-Light SDF.asset
Poppins-Medium SDF.asset
Poppins-Regular SDF.asset
Poppins-SemiBold SDF 3D.asset
Poppins-SemiBold SDF.asset
This GitHub repo here has a good guide on how to create font assets for RTL languages: https://github.com/pnarimani/RTLTMPro?tab=readme-ov-file#how-to-create-font-assets
After creating the new .asset files, rename the files to match the above and upload them to the folder replacing the existing files.
By following the implementation steps outlined above, you can seamlessly integrate RTL text capabilities into your Unity project, ensuring accessibility and readability for a wider audience.
Last updated