Don't understand how to create a bool for my code.

I’m trying to create a bool function that allows me to press a button called “Use” then once I pressed it I press another button called “Remove” which hides the panel the Use button was clicked on. I anyone could help me out and show me what to type, Id really appreciate it.

{
private int counter = 0;

public bool Return;
public GameObject[] Use;
public GameObject[] Panels;

public void Add()
{
    Panels[counter--].SetActive(true);
}

public void Remove()
{ 
    Panels[counter++].SetActive(false);

    if (Return == true)
    {
        Use[counter++].SetActive(false);
    }
}

}

Try this.

private int counter = 0;

 public bool Return;
 public GameObject[] Use;
 public GameObject[] Panels;
 bool isOn = true;
 
 public void Add()
 {
	if(isOn == true) {
     Panels[counter++].SetActive(true);
	 isOn = false;
 }
 }
 
 public void Remove()
 { 
	if(isOn == false){
     Panels[counter--].SetActive(true);
		 isOn = true;
		 }
     }
 }

The remove button removes a panel after the use button is clicked for that panel to be removed

@ashkanaral I tried this, unfortunately, this didn’t do anything to allow me to select the panel I want to remove and allow me to remove it. The sentence above explains what I meant a little better.