Sorry fixed the code. Also If I take the new list and beatStorage.add lines outside the code I wouldn’t be able to access it in the foreach statement correct?
Looks like it’s working. Should I be doing all the text stuff in void start. Then the beatStorage.add in another functions that’s called everytime you click the button?
Something like that. I was just re-reading the code and noticed I missed some things (see how good code tags are? ).
I quickly made this:
List<Studio> beatStorage = new List<Studio>();
// Call this for example in Start()
public void SetText()
{
beatText.transform.SetParent(parentPanel.transform);
beatText.color = Color.black;
beatText.fontSize = 14;
}
public void onClick()
{
beatmade++;
string beatName = "Beat" + beatmade;
beatStorage.Add(new Studio(beatName, ga.beatScore));
// No need to rewrite the entire textbox each time you click a button,
// you should be able to just add the new beat to the textbox.
beatText.text += beatName + "\n";
}
Thanks it’s working that’s great. The other problem I have is I want to randomly generate a number and save it to each beat. The variable ga.beatscore gives me an ArgumentException error. I tried moving the randomgenerator if function into the onClick function but that doesn’t work.