using System; using UnityEngine; using UnityEngine.UI; public class CardRarityColor : MonoBehaviour { public Color uncommonColor; public Color rareColor; public Color uncommonColorOff; public Color rareColorOff; private void Awake() { CardVisuals componentInParent = GetComponentInParent(); componentInParent.toggleSelectionAction = (Action)Delegate.Combine(componentInParent.toggleSelectionAction, new Action(Toggle)); } public void Toggle(bool isOn) { CardInfo componentInParent = GetComponentInParent(); if (componentInParent.rarity == CardInfo.Rarity.Uncommon) { GetComponent().color = (isOn ? uncommonColor : uncommonColorOff); } if (componentInParent.rarity == CardInfo.Rarity.Rare) { GetComponent().color = (isOn ? rareColor : rareColorOff); } } }