Random Text like Minecraft
First, sorry for my bad English.
I want to make a random text appear on the screen, just like Minecraft, how can I do this?
screenshot-3.png
(72.0 kB)
Comment
Best Answer
Answer by KevRev · Apr 27, 2019 at 09:49 AM
Try this
// At the top of the file
using System.Collections.Generic;
using UnityEngine;
// In the class
public List<string> Messages = new List<string>();
public Text mytext;
private void Start()
{
Messages.Add("message 1");
Messages.Add("message 2");
Invoke ("ChangeText",1.0f);
}
public void ChangeText()
{
mytext.text = Messages[Random.Range(0,Messages.Count)];
}
This will the text after 1 second.
Your answer
Follow this Question
Related Questions
How to change the text inside UI>Text 1 Answer
Unity 5 - Does anyone know how to scale the text in the UI? 1 Answer
CachedTextGenerator no longer has any character info in Unity 5.3 0 Answers
How do you prevent canvas text from clipping into 3D models? 1 Answer
Resizing font by scale according to screen size, (More complicated than you might think) 1 Answer