Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- using UnityEngine;
- using UnityEngine.UI;
- namespace IAP
- {
- public class PriceText : MonoBehaviour
- {
- public Text price = null;
- void Start()
- {
- if (price == null)
- price = GetComponent<Text>();
- if (price == null)
- {
- Debug.LogError("PriceText didn't find the text!");
- enabled = false;
- }
- }
- void Update()
- {
- FixPrice();
- }
- void FixPrice()
- {
- // Remove LRM RLM and controls such as new lines etc
- price.text = new string(price.text.Where(c => !(char.IsControl(c) || c == '\u200F' || c == '\u200E')).ToArray());
- }
- [ContextMenu("Test LRM RLM removal")]
- void Test()
- {
- price = GetComponent<Text>();
- price.text = '\u200F'.ToString() + "2.00$" + '\u200E'.ToString();
- FixPrice();
- Debug.Log(price.text);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment