- Home /
Question by
ani2020.bhandari · Sep 23, 2014 at 05:35 PM ·
c#texture2darrays
Changing Images at Different Instances. C# script
Hey All, I am trying to make a questionnaire type of game where my questions keep changing after a GUI button is pressed, Since I am not that great with coding(just started learning), So I am having a little trouble with arrays. I want to load a different image for a different question so I did create a script for changing questions using booleans
public Texture2D[] img;
float timeleft = 15.0f;
public static int nonmed ;
public static int med ;
public static int commerce ;
public static int arts ;
bool startq = true;
bool a = false;
bool b = false;
bool c = false;
bool d = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
timeleft -= Time.deltaTime;
if (a) {
startq = false;
}
if (b) {
a = false;
}
if (c) {
b = false;
}
if (d) {
c = false;
Application.LoadLevel(2);
}
if (timeleft <= 0) {
Application.LoadLevel (2);
}
}
void OnGUI(){
GUI.Label (new Rect (10, 10, 100, 100), timeleft.ToString ());
if (startq) {
GUI.Label (new Rect (50, 50, 900,800), "");
if (GUI.Button (new Rect (550, 400, 50, 30), "A")) {
nonmed += 1;
timeleft = 15.0f;
a = true;
}
if (GUI.Button (new Rect (700, 400, 50, 30), "B")) {
med += 1;
timeleft = 15.0f;
a = true;
}
if (GUI.Button (new Rect (550, 500, 50, 30), "C")) {
arts += 1;
timeleft = 15.0f;
a = true;
}
if (GUI.Button (new Rect (700, 500, 50, 30), "D")) {
commerce += 1;
timeleft = 15.0f;
a = true;
}
}
}
Comment
I need help with showing up different Image at every different boolean when it becomes true, and sorry for my english.
Your answer
Follow this Question
Related Questions
2D array from text file 2 Answers
A node in a childnode? 1 Answer
Combine Array of Sprites to Form One Sprite 0 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer