on Gui button pressed, other buttons deactivated

Hello,
I am using these 2 GUI buttons as info buttons.When “INFO 1” is clicked, a window with text opens with the “Close” option.But the problem is that the other GUI buttons are also active while the Info window is still opened, which is not good.What I want to do is, when I click on “INFO 1” button and the info window opens, no other button should be active until this window closes, or even better, if I have clicked to open the info window 1 and I click on the “INFO 2” button, then the text would be replaced with the text of the info window 2 and vice versa.
I think it is a “if” and “and” condition to do with this but I just don’t know how to do this. Any information or suggestion would be very helpful and greatly appreciated!!!
Thank you in advance :slight_smile:

    var showMoreGui1 = false; 
    var showMoreGui2 = false;
    
    function OnGUI () { 
        if (GUI.Button (Rect (10,Screen.height -510, 40, 40), "INFO 1")) 
            showMoreGui1 = true;
    	if (GUI.Button (Rect (10,Screen.height -450, 40, 40), "INFO 2"))
       	    showMoreGui2 = true; 
        if (showMoreGui1) { 
            GUI.Box (Rect (60,Screen.height -510,450,350), "Hello there"); 
            if (GUI.Button (Rect (60,Screen.height -510,100,20), "Close")) 
                showMoreGui1 = false; 
        } 
        if (showMoreGui2) { 
            GUI.Box (Rect (10, 40,100,20), "Hello there"); 
            if (GUI.Button (Rect (10, 70,100,20), "Close")) 
                showMoreGui2 = false; 
        } 
    } 

Usually, you have to insert && (two ampersand) between two conditions in an if or while, etc. to say that you want an AND condition. You have to use || (two vertical bars) to make an OR statement.

var showMoreGui1 = false; 
var showMoreGui2 = false;

function OnGUI () { 
    if (GUI.Button (Rect (10,Screen.height -510, 40, 40), "INFO 1") && showMoreGui2 == false) 
        showMoreGui1 = true;
	if (GUI.Button (Rect (10,Screen.height -450, 40, 40), "INFO 2") && showMoreGui1 == false)
   	    showMoreGui2 = true; 
    if (showMoreGui1) { 
        GUI.Box (Rect (60,Screen.height -510,450,350), "Hello there"); 
        if (GUI.Button (Rect (60,Screen.height -510,100,20), "Close")) 
            showMoreGui1 = false; 
    } 
    if (showMoreGui2) { 
        GUI.Box (Rect (10, 40,100,20), "Hello there"); 
        if (GUI.Button (Rect (10, 70,100,20), "Close")) 
            showMoreGui2 = false; 
    } 
} 

For your annex question, you could organize your script differently, by using enums and switches for example :

enum moreGUI
{
    none,
    firstWindow,
    secondWindow
}

private var windowToUse : moreGUI = moreGUI.none; // Variable qui sert de switch

function OnGUI()
{ 
    if(GUI.Button(Rect(10, Screen.height - 510, 40, 40), "INFO 1")) windowToUse = moreGUI.firstWindow;
    
    if(GUI.Button(Rect(10, Screen.height - 450, 40, 40), "INFO 2")) windowToUse = moreGUI.secondWindow; 

    switch(windowToUse)
    {
        case moreGUI.firstWindow:
            GUI.Box(Rect(60, Screen.height - 510, 450, 350), "Hello there"); 
            if(GUI.Button(Rect(60, Screen.height - 510, 100, 20), "Close")) windowToUse = moreGUI.none; 
            break;
        
        case moreGUI.secondWindow:
            GUI.Box(Rect(10, 40, 100, 20), "Hello there"); 
            if(GUI.Button(Rect(10, 70, 100, 20), "Close")) windowToUse = moreGUI.none; 
            break;
        case moreGUI.none:
            // Insert actions here if you want to make
            // something special when windowToUse == moreGUI.none.
            // Otherwise, you do not need to keep the case anymore.
            break;
        
        default:
            break;
    } 
}