Hello!
I need a script that allows me to selectively hide and show characters of a Text UI.
I know how to change the alpha color of text itself, but I don’t know how to analyze the Text string.
For this purpose I have a Text UI with the text component I need to check. I also have a gameobject with a bool: when this bool is true, the alpha color of a specific letter in Text UI is set to 1.
For example, let’s say I need to show every “B” letter in the Text.
Which code should I use to pick every “B” letter and set the alpha color to 1?
Thanks in advance
This is my code
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Collectible : MonoBehaviour {
public bool characterB;
public GameObject letterText;
public Color textColor;
void Update ()
{
if (characterB == true)
{
Text text = letterText.GetComponent<Text>();
text.color = textColor;
textColor.a=0;
}
}