void Awake() { if (IsAvailable) { _thisBtn = gameObject.GetComponent <DefenderSelectButton>(); _buttonArray = FindObjectsOfType <DefenderSelectButton>().Where(b => b.IsAvailable).ToArray(); _starManager = FindObjectOfType <StarManager>(); var costText = transform.FindChild("CostText"); if (costText) { costText.GetComponent <Text>().text = DefenderPrefab.GetComponent <Defender>().Cost.ToString(); } else { Debug.LogWarning(name + " has no Cost display."); } } else { this.enabled = GetComponent <Collider2D>().enabled = false; GetComponent <SpriteRenderer>().color = DisabledColor; } }
void OnMouseDown() { SelectedDefender = SelectedDefender == _thisBtn ? null : _thisBtn; }