Assigning two variables ?

Hi everyone,

I’m trying to make three GUI buttons. I want to hit one button and disables the other two and vice versa.

I’m using the variables “emble” and “bate” in order to enable and disable the buttons,

Now I have problems trying to get working my function “function tool(){” so I can enable or disables the other two.

thanks in advance for your help.

Please take a look to my function Tool

    function tool(){
    if(bate == true && emble == true){
    bate == false && emble == false;
    yield WaitForSeconds (2.5);
    bate == true && emble == true;
    }
    }

Please take a look to the script,

    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),"")){
	tool();           
    }
    } 
 
     
    //FUNCTIONS//////////////////////////////////////
     
    function battery(){
    if(bate == true){
    bate = false;
    yield WaitForSeconds (2.5); 
    bate =true;     
    }
    }
   

    function disassemble(){
    if(emble == true){
    emble = false;
    yield WaitForSeconds (2.5);   
    emble = true;
    }
    }
 

    function tool(){
    if(bate == true && emble == true){
    bate == false && emble == false;
    yield WaitForSeconds (2.5);
    bate == true && emble == true;
    }
    }

1 Answer

1

boolean button1 = true;
boolean button2 = true;
boolean button3 = true;

function OnGUI (){
    if (button1 && GUI.Button(Rect(870,100,80,80),"")){
       button1=true;
       button2=false;
       button3=false;
    }
    if (button2 && GUI.Button(Rect(870,300,80,80),"")){
       button1=false;
       button2=true;
       button3=false;
    }
    if (button3 && GUI.Button(Rect(870,500,80,80),"")){
       button1=false;
       button2=false;
       button3=true;
    }
}

FL, Thanks works Perfectly :) Thanks again!