- Home /
Question by
karkadayn · Sep 23, 2021 at 02:41 PM ·
instantiatecolor changeforeach
Problems with color change.
Hello everyone, I am making a game with a set of text, I am facing a gap with a color change. My words go one by one for example Bob, "b" "o" "b". I create an instance of gameobject letters and then change the color of letters and for some reason only one letter changes, although they should change 3. HELP PLEASE !!
public Text wordOutput; public GameObject letters;
private void SetCurrentWord()
{
SetRemaininWord(currentWord);
foreach ( char c in remaininWord)
{
wordOutput.text = c.ToString();
Instantiate(letters, FindObjectOfType<CanvasText>().transform);
}
}
private bool IsCorrectLetter(string letter)
{
letters.GetComponent<Image>().color = new Color32(1, 255, 0, 255);
return remaininWord.IndexOf(letter) == 0;
}
Comment