Random string element from array for a print command

Hi,

I’ve been searching all over the internet for this answer and still haven’t been able to find it. I have a string array variable, and want to have it accessed randomly in print commands. Here’s the essence of the code (It’s been simplified):

var example : String[ ]; // Values defined in the editor

if (GUI.Button(Rect (10,10,100,10), “Example Button”))
{
print(example);
}

The button part of it works fine (I’ve tested it). I know the print command isn’t going to bring me what I want, but my question is what will?

Thanks

Random.Range() will generate a random value. You can use that to represent your array member. So…

var rndm : int = Random.Range(0, example.length);
print (example[rndm]);