Hello All,
I have a task like displaying questions if i click the next button.
I wrote code like this:
using UnityEngine;
using System.Collections;
public class Arrayquestions : MonoBehaviour {
private Rect windowRect6 = new Rect(Screen.width/2,Screen.height/2, 600, 100);
private bool questionbool1;
public ArrayList question,options;
public string[,] opti;
public GUIStyle newfontStyle;
private bool toggleTxt1 = false,toggleTxt2 = false,toggleTxt3 = false,toggleTxt4 = false;
string op;
void Start () {
question= new ArrayList(){"A pendulum length is 20m , find the Timeperiod of the pendulum ?","A pendulum timeperiod is 10sec , find the length of the pendulum ?"};
options=new ArrayList(){"8.965s,7.965s,10.965s,9.965s,1","15m,25m,17m,18m,2"};
opti= new string[,]{{"8.965s","7.965s","10.965s","9.965s","1"},{"15m","25m","17m","18m","2"}};
}
// Update is called once per frame
void OnGUI () {
if(GUI.Button(new Rect(Screen.width-(Screen.width/4),523,130,60),"Assignment"))
{
questionbool1 = true;
}
if(questionbool1)
{
windowRect6 = GUI.Window(4, windowRect6, DoMyWindow6, "");
}
}
void DoMyWindow6(int windowID)
{
if(GUI.Button(new Rect(450,50,70,30), "NEXT"))
{
print ("hi click");
//foreach(string s in question)
for (int i=0;i<2;i++)
{
GUI.Label(new Rect(10,10,500,100),question*.ToString(),newfontStyle);*
-
}*
-
//foreach(string o in options)*
-
//for(int j=0;j<4;j++)*
-
//{*
-
for(int i=0,j=0; i<2 && j<4; i++,j++)*
-
{*
-
toggleTxt1 = GUI.Toggle(new Rect(30, 50, 100, 40), toggleTxt1, "");*
-
toggleTxt2 = GUI.Toggle(new Rect(130, 50, 100, 40), toggleTxt2, "");*
-
toggleTxt3 = GUI.Toggle(new Rect(250, 50, 100, 40), toggleTxt3, "");*
-
toggleTxt4 = GUI.Toggle(new Rect(350, 50, 100, 40), toggleTxt4, "");*
-
}*
-
//} *
-
}*
-
}*
}
If i click the NEXT button I’m not able to get the questions.