title: How can I get my Ui Buttons to switch colors in Unity?
body: <p>I'm working on a basic Match three in Unity using only the UI. For the objects to match I'm using the UI buttons and having the objects be different colors. For having the objects switch palaces I have a method that switches the color of the buttons. My difficulty is in calling the method upon pressing the buttons.</p>
  
  <pre><code>using UnityEngine;
  using UnityEngine.UI;
  using System.Collections;
  
  public class match : MonoBehaviour {
  
  public float time = 30.0f;
  public float _score;
  public GameObject pausePanel;
  private Color[] colors = new Color[3];
  //public Button[] buttons;
  private Image[] image = new Image[16];
  public Image im1;
  public Image im2;
  public Image im3;
  public Image im4;
  public Image im5;
  public Image im6;
  public Image im7;
  public Image im8;
  public Image im9;
  public Image im10;
  public Image im11;
  public Image im12;
  public Image im13;
  public Image im14;
  public Image im15;
  public Image im16;
  public Image b;
  public Image c;
  public Image temp;
  
  void Start () {
      _score = 0.0f;
      colors [0] = Color.red;
      colors [1] = Color.blue;
      colors [2] = Color.green;
      image [0] = im1;
      image [1] = im2;
      image [2] = im3;
      image [3] = im4;
      image [4] = im5;
      image [5] = im6;
      image [6] = im7;
      image [7] = im8;
      image [8] = im9;
      image [9] = im10;
      image [10] = im11;
      image [11] = im12;
      image [12] = im13;
      image [13] = im14;
      image [14] = im15;
      image [15] = im16;
  }
  
  void Update () {
  
      time -= Time.deltaTime;
  
      if (time &lt;= 0) {
          time = 0.0f;
      }
  
      if (time == 0 &amp;&amp; _score == 0) {
          pausePanel.SetActive (true);
      }
      AssignColor (); 
  }
  
  void OnGUI()
  {
      GUI.Box (new Rect (10, 10, 30, 20), "" + time.ToString ("0"));
      GUI.Box (new Rect (85, 410, 30, 20), "" + _score.ToString ("0"));
  }
  
  void AssignColor()
  {
      foreach (Image i in image) {
          int colornum = Random.Range (0, colors.Length);
          if(i.color == Color.white){
              i.color = colors[colornum];
          }
      }
  
  }
  
  public void getButton(Image i)
  {
      if (b == null) {
          b = i;
      } 
      else if (c == null) {
          c = i;
      }
  
      if (b != null &amp;&amp; c != null) {
          Swap(b, c);
          b = null;
          c = null;
      }
  }
  
  void Swap(Image ac, Image bc)
  {
      //Image temp;
      temp.color = ac.color;
      ac.color = bc.color;
      bc.color = temp.color;
  
  }
  }
  </code></pre>
  
  <p>I have all my buttons in my Inspector able to activate getButton, and the image are being taking by Image b or Image C upon pressing the button but they are not switching colors.</p>