I’ve made a game menu with GUIStyle Button. Everything works great, but when I make another GUIStyle for a floating background texture (a glass behind the menu buttons), the button don’t triggers anymore.
e.g.
var Button1 : GUIStyle;
var Back_Glass: GUIStyle;
var Error : GUIStyle;
var NoPoints : boolean = false;
var Points : int = 0;
function OnGUI () {
GUI.Button (Rect (Screen.width/2-450,Screen.height/2-140,900,350), "", Back_Glass);
if (Button1_Enable == false){
if (GUI.Button (Rect (Screen.width/2-400,Screen.height/2,200,70), "", Button1)){
if (Points >= 10){
Button1_Enable = true;
Points = (Points - 10);
}
else {
NoPoints = true;
StartCoroutine("CountDown");
}
}
if (NoPoints == true){
GUI.Button (Rect (Screen.width/2-128,Screen.height-96, 256,32), "", Error);
}
}
function CountDown(){
yield WaitForSeconds(2);
NoPoints = false;
}
In this code, if the button is pressed, and the player don’t have enough points to enable the level, the button triggers a message that appear (for 2 second using StartCoroutine).
The message don’t appears if I use the glass background, but appears normally if I set none texture or remove the code.
I know I’m using a GUI Button to show a texture only, but as I’m new to scripting, and couldn’t find another way to make the floating background to the menu buttons.
Thanks.