Cycle through UI text randomly at interval


I am wondering what the best way to achieve this would be in Unity:

I have a series of different pieces of text that I want to display, one at a time (randomly), and changing after a 10 sec period. The number of different texts that I have to display will be around 500.

At the moment I am using a UI Text object for each different piece of text and I have a timer that runs on a 10 sec loop ready to trigger the changes.

Would it be best to somehow create a list at scene load that stores a reference to these objects which can then be used to get the component. Or is there a better way to do this?

I am new to lists so I have no reference here.


Here’s some code. Texts is a list of your “different pieces of text.” text is a reference to a text UI display (you don’t need this, you can just use something else)

float t = 0;
public List<string> Texts;
public Text text;

void Update () {
  t += Time.deltaTime;
  if (t >= 10) {
    t = 0;
    text.text = Texts[Random.Range(0, Texts.Count()];

Hope this helps!