The below code is what I’ve come up with so far to do what I want. Basically I want to have a string (in this case SEAMLESS) and for each letter in this string I want to cycle through random letters until they are the same. When they are the same I want to save them in the array of letters and then at the end form the word. The goal is to get an effect similar to [this][1] but with letters instead of numbers.
public string word = "SEAMLESS";
private string builtWord;
public char[] letters;
public Text displayBox;
string uppercaseAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private void Start()
{
letters = word.ToCharArray();
}
private void Update()
{
for (int i = 0; i < letters.Length; i++)
{
char randomLetter = UppercaseLetter();
while (randomLetter != letters*)*
{
letters = randomLetter;
print("letter: " + letters);
print("random letter: " + randomLetter);
if (randomLetter == letters*)*
{
builtWord = builtWord + letters*;*
print("built word: " + builtWord);
return;
}
randomLetter = UppercaseLetter();
return;
}
if (randomLetter == letters*)*
{
}
}
}
public char UppercaseLetter()
{
char letter = uppercaseAlphabet[Random.Range(0, uppercaseAlphabet.Length)];
//letter = (char)(‘A’ + Random.Range(0, 26)); //Alternative way of getting letter using ASCII
return letter;
}
_*[1]: https://forum.unity.com/threads/make-a-text-count-up-from-zero-to-value-score-results-screen-for-game.380209/*_