void Start() { uiControl = FindObjectOfType<UIController>(); hex = GetComponentInParent<Hex>(); hexTrait = hex.GetGeography(); hexVal = (int)hexTrait; icon = GetComponent<Image>(); icon.sprite = uiControl.GetGeoSprite(hexTrait); icon.color = uiControl.GetGeoSpriteColor(hexTrait); }
void Update() { prevVal = hexVal; hexTrait = hex.GetGeography(); hexVal = (int)hexTrait; icon = GetComponent<Image>(); if(hexVal != prevVal){ prevVal = hexVal; icon.sprite = uiControl.GetGeoSprite(hexTrait); icon.color = uiControl.GetGeoSpriteColor(hexTrait); } }