title: How to change alpha of a sprite through script in Unity
body: <p>I have 4 buttons and they each flash when the button is pressed. However if you were to press a button, then while the button is darker (flashing) click another one, that button then stays dark. I want to reset the color of the sprite before disabling them however it's not working. When the buttons are pressed they no longer flash....</p>
  
  <p>Here is the code:</p>
  
  <pre><code>void Start () {
          easy.GetComponent&lt;SpriteRenderer&gt;().color = color;
      }
  
      void Update () {
          if(difficultySelected[0] == true){
              enemyBehavior.shotsPerSecond = 0.2f;
              //Enabling the selected button
              easy.enabled = true;
  
              //Reseting the colors
              normal.GetComponent&lt;SpriteRenderer&gt;().color = color;
              hard.GetComponent&lt;SpriteRenderer&gt;().color = color;
              expert.GetComponent&lt;SpriteRenderer&gt;().color = color;
  
              //Disabling the 'unselected' buttons
              normal.enabled = false;
              hard.enabled = false;
              expert.enabled = false;
  
              easy.Play("Difficulty");
          }else if(difficultySelected[1] == true){
              enemyBehavior.shotsPerSecond = 0.5f;
              normal.enabled = true;
  
              easy.GetComponent&lt;SpriteRenderer&gt;().color = color;
              hard.GetComponent&lt;SpriteRenderer&gt;().color = color;
              expert.GetComponent&lt;SpriteRenderer&gt;().color = color;
  
              easy.enabled = false;
              hard.enabled = false;
              expert.enabled = false;
  
              normal.Play("Difficulty");
          }else if(difficultySelected[2] == true){
              enemyBehavior.shotsPerSecond = 1;
              hard.enabled = true;
  
              easy.GetComponent&lt;SpriteRenderer&gt;().color = color;
              normal.GetComponent&lt;SpriteRenderer&gt;().color = color;
              expert.GetComponent&lt;SpriteRenderer&gt;().color = color;
  
              easy.enabled = false;
              normal.enabled = false;
              expert.enabled = false;
  
              hard.Play("Difficulty");
          }else if(difficultySelected[3] == true){
              enemyBehavior.shotsPerSecond = 2;
              expert.enabled = true;
  
              easy.GetComponent&lt;SpriteRenderer&gt;().color = color;
              normal.GetComponent&lt;SpriteRenderer&gt;().color = color;
              hard.GetComponent&lt;SpriteRenderer&gt;().color = color;
  
              easy.enabled = false;
              normal.enabled = false;
              hard.enabled = false;
  
              expert.Play("Difficulty");
          }
      }
  </code></pre>