private void calculateTotal() { int unused = getUnused(); if (lastUnused == unused) { return; } lastUnused = unused; if (unused > 1) { if (counter == null || !counter.IsActive()) { createCounter(); } ((UnityEngine.UI.Button)counter).image.sprite = getNumberIcon(unused); } else { UnityEngine.Object.Destroy(icon); } Image image = GetComponent <Image>(); Color c = image.color; c.a = unused == 0? .5f : 1; image.color = c; }