Hi!
I am trying to create something like a sort of a dialog box where I can show word-by-word of a string with a delay. But when the text inside the text box exceeds the maximum character capacity and can not display the new word anymore, I want to clean up that text box. The problem is that I don’t know how to compare and identify which is the maximum character capacity inside the Text box.
What I’ve accomplished so far is just that:
public string sampleText; // Text to be displayed in the dialog box
public Text sampleTextBox; // dialog box inside canvas
public float textDelay; // delay between word display
public IEnumerator GenerateText()
{
string[] sampleTextArray = sampleText.Split(); ; // Array that splits the string, separeting by the spaces.
sampleTextBox.text = ""; // Cleanning up the dialog box.
foreach (string s in sampleTextArray) //For each word in the array of words from string to be displayed
{
// IF sampleTextBox.text + WHAT I WANT TO DISPLAY <= MAX CHARACTER CAPACITY IN DIALOG BOX
// sampleTextBox.text += WHAT I WANT TO DISPLAY
// ELSE
// sampleTextBox.text = ""; // Cleanning up the dialog box.
// sampleTextBox.text += WHAT I WANT TO DISPLAY
// sampleTextBox.text += " " // ADDING SPACE BETWEEN WORDS
}
}
Thanks for reading this far!
If you want any clarification to answer my question, you can ask.