listing loop

hello,
I have a list of text files each fille has questions

  • and answers

  • I wanted to put every list of questions in round data but I didn’t succeed.
    all the questions go together in all-round data. I tried to make questions empty by clearing it after the loop but it makes all the question is empty. any solution plz?
    thanks in advance
    public void loadData()
    {
    List textAssets = new List();
    TextAsset stagedata = Resources.Load(“stage00”);
    TextAsset s01 = Resources.Load(“s01”);
    TextAsset s02 = Resources.Load(“s20”);
    TextAsset s03 = Resources.Load(“s113”);
    textAssets.Add(stagedata);
    textAssets.Add(s01);
    textAssets.Add(s02);
    textAssets.Add(s03);
    for (int j = 0; j < textAssets.Count; j++) {

//TextAsset stagedata = Resources.Load(“stage00”);
string[ ] qdata = textAssets[j].text.Split(new char[ ] { ‘\n’ });

for (int i = 0; i < qdata.Length; i++)
{
string[ ] raw = qdata*.Split(new char[ ] { ‘,’ });*

  • Question q = new Question();*
  • allanswers = new List();*
  • Answer anw1 = new Answer(raw[1], true);*
  • Answer anw2 = new Answer(raw[2], false);*
  • Answer anw3 = new Answer(raw[3], false);*
  • Answer anw4 = new Answer(raw[4], false);*
  • allanswers.Add(anw1);*
  • allanswers.Add(anw2);*
  • allanswers.Add(anw3);*
  • allanswers.Add(anw4);*
  • q.questiontxt = raw[0];*
  • q.answers = allanswers;*
  • questions.Add(q);*
  • }*
  • Roundata round = new Roundata();*
  • round.questions = questions;*
  • allroundata.Add(round);*
  • allroundata[j].levelnumber = j;*
  • allroundata[j].roundscoreadded = 10;*
  • allroundata[j].timeLimit = 15;*
  • allroundata[j].life = 3;*
  • //questions.clear();*
  • }*

Please use code tags: https://discussions.unity.com/t/481379

How to report problems productively in the Unity3D forums:

http://plbm.com/?p=220

You probably want a more data-driven solution that puts all the data into a file (I recommend using JSON since Unity can use it) and configure your program to load the datafile and operate on ie.