public void changeSprite() { Image img = this.transform.GetChild(0).GetComponent <Image>(); if (img != null) { img.sprite = spriteLib.sprites[spriteLib.CardToSprite(card)]; } else { SpriteRenderer sr = this.transform.GetChild(0).GetComponent <SpriteRenderer>(); sr.sprite = spriteLib.sprites[spriteLib.CardToSprite(card)]; } }