Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Copyright (c) 2016-2020 Kai Clavier [kaiclavier.com] Do Not Distribute
- //Made to work with Arabic Letters Support for Unity by Abdullah Konash [https://github.com/Konash/arabic-support-unity]
- using UnityEngine;
- using System.Collections;
- using ArabicSupport;
- using System.Text; //for stringbuilder
- /*
- This will alo fix ordering for other RTL languages! I need to rename this script...
- Tag order code still isn't ideal... but it's a working solution for now!
- In the future I'd like to get the tags respecting RTL rules, too.
- */
- [ExecuteInEditMode]
- [RequireComponent(typeof(SuperTextMesh))]
- public class STMArabicSupport : MonoBehaviour
- {
- public SuperTextMesh superTextMesh;
- [Tooltip("Sending other-language strings through the fixer can cause issues, so this is here so things can be quickly disabled in localized games.")]
- public bool isEnabled = true;
- //[Tooltip("Make sure this value matches the way your text was typed up!! Otherwise it will cause an error.")]
- public bool rtlTags = true;
- public bool showTashkeel = false;
- public bool combineTashkeel = false;
- public bool useHinduNumbers = false;
- public static bool disableAll = false;
- void Reset()
- {
- superTextMesh = GetComponent<SuperTextMesh>();
- }
- void OnEnable()
- {
- superTextMesh.OnPreParse += FixText;
- //Debug.Log("subscribing");
- }
- void OnDisable()
- {
- superTextMesh.OnPreParse -= FixText;
- //Debug.Log("Unsubscribing");
- }
- void FixText(STMTextContainer container)
- {
- if(isEnabled && !disableAll)
- {
- //fix the string within the container
- //container.text = ArabicFixer.Fix(container.text, rtl);
- string fixedString = ArabicFixer.Fix(container.text, showTashkeel, combineTashkeel, useHinduNumbers);
- if(rtlTags)
- {
- fixedString = fixedString.Replace('<', 'ξ'); //null for now
- fixedString = fixedString.Replace('>', '<');
- fixedString = fixedString.Replace('ξ', '>');
- }
- container.text = fixedString;
- }
- }
- }
Add Comment
Please, Sign In to add comment