Hello there,
I am trying to make an Dialogue system(I dont want to use any plugins as this is a learning procces for me). But the ArrayLists are giving me other information then expected. This is my code:
private ArrayList Questions = new ArrayList();
private ArrayList Answers = new ArrayList();
//public Texture CharacterTexture;
void Start () {
Answers.Add("Doorgaan?");
Answers.Add("nee");
Answers.Add("ja");
Questions.Add(Answers);
Answers.Clear();
Answers.Add("En wat nu weer?");
Answers.Add("aaaa");
Answers.Add("bbbb");
Questions.Add(Answers);
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
if(GUI.Button(new Rect(Screen.width / 2 - 150,250,300,50),((ArrayList)Questions[0])[0].ToString())){
Debug.Log("Je hebt nu op nr 0 geklikt");
}
if (GUI.Button(new Rect(Screen.width / 2 - 150, 300, 300, 50), ((ArrayList)Questions[0])[1].ToString()))
{
Debug.Log("Je hebt nu op nr 1 geklikt");
}
if (GUI.Button(new Rect(Screen.width / 2 - 150, 350, 300, 50), ((ArrayList)Questions[0])[2].ToString()))
{
Debug.Log("Je hebt nu op nr 2 geklikt");
}
Now I expect ‘Questions[0])[0]’ to display “Doorgaan?”, ‘Questions[0])[1]’ “Nee” etc. But instead it is showing me “en wat nu weer?”, “aaaa” and “bbbb”…
How can I fix it? What am I doing wrong in my code?
Thank you for your time