title: Make Button Toggle a GameObject On and Off
body: <p>I'm stuck on this one. I have two buttons that are each associated with a respective pop-up that I would like to show when the buttons are clicked and then hide when the buttons are clicked again and so on. I know I need to invert the boolean using '!' but I'm not exactly sure how to implement it in my code below. What is the correct way that my PaletteState function should be written? Thanks!</p>
  
  <pre><code>using UnityEngine ;
  using System.Collections ;
  using UnityEngine.UI ;
  
  public class ShowHidePalettes : MonoBehaviour
  {
      public Button changeColorButton ;
      public GameObject colorPalette ;
      public Button brushSizeButton ;
      public GameObject brushSizePalette ;
  
      void Awake ()
      {
          changeColorButton.onClick.AddListener (() =&gt; PaletteState (colorPalette, true)) ;
          brushSizeButton.onClick.AddListener (() =&gt; PaletteState (brushSizePalette, true)) ;
      }
  
      void Start ()
      {
          PaletteState (colorPalette, false) ;
          PaletteState (brushSizePalette, false) ;
      }
  
      public void PaletteState (GameObject _palette, bool _visible)
      {
          _visible = !_visible ;
  
          if (_visible == true)
          {
              _palette.SetActive (true) ;
          } else
          {
              _palette.SetActive (false) ;
          }
      }
  }
  </code></pre>