title: Why won't my sprite change during runtime?
body: <p>On my scene view in unity, I have three gameobjects set up, each with a respective sprite renderer and sprites. Two of the three are smaller in dimensions than the third one.</p>
  
  <p>The images displayed by both smaller sprites are different. What I'd like to do is to be able to change the sprite of the third one by clicking on the other two. Clicking on one of the smaller sprites will make the third larger sprite match the small sprite that was previously clicked.</p>
  
  <p>Here are the relevant scripts assigned to the two smaller sprites.</p>
  
  <p>1st one that handles which sprite is displayed on the small sprite:</p>
  
  <pre><code>public class CardModel : MonoBehaviour
  {
      SpriteRenderer spriteRenderer;  // renders sprite
  
      public int cardIndex;       // indicates what the card is
      public bool show;           // shows or hides card
  
      public Sprite[] cardFronts; // collection of cards' front sides
      public Sprite cardBack;     // backside of all cards
  
      // if card is turned up, show front of card, show back otherwise
      public void DisplaySprite()
      {
          if (show)
              spriteRenderer.sprite = cardFronts[cardIndex];
          else
              spriteRenderer.sprite = cardBack;
      }
  
      void Awake()
      {
          spriteRenderer = GetComponent&lt;SpriteRenderer&gt;();    // retrieve our sprite renderer
          DisplaySprite();                                         // show card's sprite
      }
  }
  </code></pre>
  
  <p>And 2nd one that makes the smaller sprites clickable:</p>
  
  <pre><code>public class ClickCard : MonoBehaviour
  {
      CardModel model; // used to retrieve card index and bool to assign to larger sprite
  
      public GameObject largeSprite; // third large sprite
  
      void OnMouseDown()
      {
          CardModel cModel = GetComponent&lt;CardModel&gt;(); // retrieve card model from smaller sprite
          LargeCardModel largeCardModel = largeSprite.GetComponent&lt;LargeCardModel&gt;(); // retrieve card model for larger sprite
  
          largeCardModel.matchSprite(cModel.show, cModel.cardIndex); // match large sprite with small sprite clicked
      }
  }
  </code></pre>
  
  <p>And finally, the script attached to the third large sprite:</p>
  
  <pre><code>public class LargeCardModel : MonoBehaviour
  {
      public int largeIndex; // determines which sprite to show
  
      public Sprite[] largeCardFaces; // collection of large sprites
      public Sprite largeCardBack; // large card back
  
      SpriteRenderer largeRenderer; // renders the image upon the large sprite
  
      void Awake()
      {
          largeRenderer = GetComponent&lt;SpriteRenderer&gt;(); // retrieve renderer
      }
  
      // method to allow sprite to be changed
      public void matchSprite(bool showFace, int cIndex)
      {
          if (largeRenderer == null)
              largeRenderer = GetComponent&lt;SpriteRenderer&gt;(); // for some reason, I need to include this line or else I get an exception
  
          if (showFace)
              largeRenderer.sprite = largeCardFaces[cIndex];
          else
              largeRenderer.sprite = largeCardBack;
      }
  }
  </code></pre>
  
  <p>For whatever reason, I can't get the image to the larger sprite to change during runtime however when I stop running the program, the large sprite changes to that of the last smaller sprite I clicked on.</p>