So for the game i am making i require an array to hold 50 string elements. What i want to happen is when the player pushes a button the script randomly chooses a number and finds the corrosponding element. I then want the script to then show the selected element in some sort of GUI output such as a label. I get it to work but after a random number of presses i get an error saying it cannot cast from source type to destination type. I was thinking of changing the script to C# and use lists but the sake of continuity i was just seeing if what i could do was possible.
function OnGUI() {
GUI.Label(Rect(50,50,50,50),ChosenSong,"label");
if (GUI.Button(Rect(Screen.width/2,Screen.height/2,150,50),Toggle)){
Song = Random.Range(0,playlist.length);
ChosenSong = playlist[Song];
playlist.RemoveAt(Song);
}
}