So, I have two buttons. When I click on one, it pops up another element with a Button in it. That second button is slightly overlapping the first button. When I click on the overlapped portion nothing happens. Neither of them do what is inside the if statement. How do I fix this to where just the second button is clickable, and the first isn’t. I want them both viewable, as the first button is only partially overlapped.
private var gunClicked=0;
private var showSelectionScreen=false;
private var stopClick=false;
function OnGUI () {
GUI.Box(Rect(50,50,Screen.width-100,Screen.height-100),"");
GUI.Box(Rect(100,100,Screen.width-200,Screen.height-200),"Ship Layout");
if(GUI.Button(Rect(Screen.width/3-50,200,100,100),"Gun 1")&showSelectionScreen==false){
gunClicked=1;
}
if(GUI.Button(Rect(Screen.width/2-50,200,100,100),"Gun 2")&showSelectionScreen==false){
gunClicked=2;
}
if(GUI.Button(Rect(Screen.width/3*2-50,200,100,100),"Gun 3")&showSelectionScreen==false){
gunClicked=3;
}
if(GUI.Button(Rect(Screen.width/3-50,450,100,100),"Gun 4")&showSelectionScreen==false){
gunClicked=4;
}
if(GUI.Button(Rect(Screen.width/2-50,450,100,100),"Gun 5")&showSelectionScreen==false){
gunClicked=5;
Debug.Log("Clicked");
}
if(GUI.Button(Rect(Screen.width/3*2-50,450,100,100),"Gun 6")&showSelectionScreen==false){
gunClicked=6;
}
if(showSelectionScreen==true){
GUI.Box(Rect(Screen.width/2-150,Screen.height/2-100,300,200),"");
GUI.Button(Rect(Screen.width/2-140,Screen.height/2-75,280,50),"Update Turret Hardpoint");
GUI.Button(Rect(Screen.width/2-140,Screen.height/2-20,280,50),"Take Control of Hardpoint "+gunClicked);
if(GUI.Button(Rect(Screen.width/2-50,Screen.height/2+35,100,50),"Cancel")){
showSelectionScreen=false;
gunClicked=0;
Debug.Log("Cancel");
}
}
if(gunClicked!=0&showSelectionScreen==false){
showSelectionScreen=true;
Debug.Log("Show");
}
}