Hi Everyone,
I am making four player game where players answer questions through the GUI and it changes what happens in a 3D world. I am just starting this project and before I dig in too deep I want to see if anyone else has any better ideas on how to execute this.
So far I have been scripting everything in the function OnGui. However, I can already tell that to do this for four players I am going to need a ton of different boolean variables and the size of my code is going to get ridiculous.
Basically what I want to have happen is this. Player One puts in there name and presses a button to go on. That creates a new GUI.TextArea where the player can enter a new answer (string or value). This continues on and on. After questions where a string is required there is a fail safe that allows the player to go back and fix their answer (in case of misspelling).
Below is my code. As you can see the player can enter their name and then decide whether to go forward or back. I have not even started to ask my questions yet and I’m worried that with many questions and four players… that this is not only going to take forever but my code is going to be ridiculously long!!!
#pragma strict
var ButtonOne : boolean = false;
var GUIEnabledOne : boolean = false;
var PlayerOne : String;
var VerifyButtonOne : boolean = false;
function OnGUI (){
if (GUIEnabledOne == false){
PlayerOne = GUI.TextArea (Rect(10,20,200,50), PlayerOne, 200);
GUI.Label (Rect (30, 0, 200, 50), "Player One Enter Your Name");
}
if (ButtonOne == false) {
if (GUI.Button (Rect (210,20,100,50), "Next")) {
GUIEnabledOne = true;
print(PlayerOne);
ButtonOne = true;
VerifyButtonOne = true;
}
}
if (VerifyButtonOne == true){
if (GUI.Button (Rect (210,20,100,50), "Next")){
}
GUI.Label (Rect (110, 20, 100, 50), "Welcome " + PlayerOne);
if (GUI.Button (Rect (0,20,100,50), "Back")){
}
}
}