- Home /
Ui Button with multiple text prompts
I am currently trying to create a quick tutorial at the start of the game with several blocks of text to give instructions on how to play, but so far I can only change the text once with the button. My question is how do i go through all the text screen (5 in total) by pressing the same UI button?
Comment
Answer by KittenSnipes · Mar 13, 2018 at 07:41 AM
Well you can hold a list of all the text you want to change like such:
public Text textToChange;
public List<string> tutorialMessages;
int textInt;
void Start()
{
textInt = 0;
textToChange.text = tutorialMessages[textInt];
Debug.Log(tutorialMessages[textInt]);
}
public void ChangeText()
{
textInt += 1;
if (textInt < (tutorialMessages.Count))
{
textToChange.text = tutorialMessages[textInt];
Debug.Log(tutorialMessages[textInt]);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612154455im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Text isn't showing up on button 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Help with making a triggered gui message 1 Answer
Reading from a .txt file until a certain character is detected 1 Answer