title: Avoid UI buttons to run function twice after fast click
body: <p>How do I avoid my UI buttons to run functions twice if clicked (accidentally) twice or more in a short time?</p>
  
  <p>I have a UI button that calls a StartGame function in my game script. I attached the script to the button in the inspector. The function sets a few variables in order for the game to start.</p>
  
  <p>If I accidentally click the button twice really quickly, the start function is executed twice and thus it screws up my variables. How do I avoid that?</p>
  
  <p>I am thinking of splitting up the function so that it checks if it's already started, but that seems like a bit complex. Isn't there a standard setting in Unity UI or some standard code I missed? Tried to google but not much luck.</p>
  
  <p>Simplified example of my code:</p>
  
  <pre><code>public void StartGame() {
  
  MenuAnimator.SetBool ("Startbutton", false); // animates my start game panel off the screen.
  lives = lives - 1;
  Do Rest of Code();
  }
  </code></pre>
  
  <p>In this case, clicking the UI menu Start Game button multiple times causes two or more lives to be deducted. </p>