public void SelectTurret(GameObject turretGO, ShopButtonUI button) { if (turretGO == selectedTurret) { selectedButtonUI.Deselect(); selectedTurret = null; button = null; return; } // 1) disselect turret if (selectedButtonUI != null) { selectedButtonUI.Deselect(); } // 2) = selectedTurret = turretGO; selectedButtonUI = button; // select Turret turret = selectedTurret.GetComponent <Turret>(); SetTurretData(turret?.CurrentTurret); selectedButtonUI.Select(); void SetTurretData(TurretObject data) => turretData = data; }
public void SetTurrets(TurretObject[] turrets) { foreach (TurretObject t in turrets) { GameObject newTurretButton = Instantiate(TurretButton); newTurretButton.transform.SetParent(transform); ShopButtonUI sbui = newTurretButton.GetComponent <ShopButtonUI>(); sbui?.Init(t); } }
public void TurretPressed(GameObject newTurret, ShopButtonUI button) => buildManager.SelectTurret(newTurret, button);