- Home /
GUI.enabled ?
Hi everyone,
I'm trying to make three GUI buttons, but I want to hit each button so I can disable the other two buttons and reverse to the previous state.
I'm using GUI.enabled to re-enabled and enabled my GUI buttons.
My first button has the function "GUI.enabled = bate;"
My second button has the function "GUI.enabled = emble;"
And my third button has a boolean function "GUI.enabled = GetABooleanValue();"
Now I can't re-enabled my third button, please take a look to my function I did try to make it works, please help.
function ve(){
if(GetABooleanValue == true){
GetABooleanValue = false;
yield WaitForSeconds (2.5);
GetABooleanValue == true;
}
}
Please take a look to the whole Script
static var triggerGo : int;
static var cameraGo : int;
var Skin_tool : GUISkin;
var Skin_battery : GUISkin;
var Skin_Disassemble : GUISkin;
var beep : AudioClip;
var bate = true;
var emble = true;
private function GetABooleanValue(): boolean{
if(bate == false && emble == false){
return true;
}else{ if(bate == false && emble == true){
return false;
}else{
if(bate == true && emble == false){
return false;
}else{
return true;
}
}
}
}
//GUI BUTTONS///////////////////////////
function OnGUI (){
//TOOL//////////////////////////////////
GUI.enabled = bate;
GUI.skin = Skin_tool;
if (GUI.Button(Rect(870,345,80,80),"")){
disassemble();
}
//BATTERY///////////////////////////////
GUI.enabled = emble;
GUI.skin = Skin_battery;
if (GUI.Button(Rect(870,470,80,39),"")){
battery();
}
//DISASSEMBLE///////////////////////////
GUI.enabled = GetABooleanValue();
GUI.skin = Skin_Disassemble;
if (GUI.Button(Rect(870,512,80,80),"")){
ve();
}
}
//FUNCTIONS/////////////////////////////
function battery(){
if(bate == true){
bate = false;
yield WaitForSeconds (4.5);
bate =true;
}
}
function disassemble(){
if(emble == true){
emble = false;
yield WaitForSeconds (2.5);
emble = true;
}
}
function ve(){
if(GetABooleanValue == true){
GetABooleanValue = false;
yield WaitForSeconds (2.5);
GetABooleanValue == true;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613092021im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Assigning two variables ? 1 Answer
Customizing GUI buttons 1 Answer
Putting Dictionary/List using foreach as buttons in a scroll view? 3 Answers
GUI Display Help 0 Answers