Ejemplo n.º 1
0
 //true: btnManager save the activate state of the button
 //false: btnManager doesn't save the activate state of the button
 public void OnButtonClick(ButtonElement btn, bool saveState)
 {
     //if there are no current activated button -> activate the given button and save it
     if (currentBtn == null)
     {
         btn.Activate();
         if (saveState)
         {
             currentBtn = btn;
         }
     }
     //if the current activate btn is the same as the given one
     //-> deactivate it and remove the saved btn
     else if (currentBtn == btn)
     {
         currentBtn.Deactivate();
         currentBtn = null;
     }
     //if the current activate btn is not the same
     //-> deactivate the current, save the given and activate it
     else
     {
         currentBtn.Deactivate();
         btn.Activate();
         if (saveState)
         {
             currentBtn = btn;
         }
     }
 }