public void ConfirmUnitTraining() { if (UnitName.Length == 0) { string randomName = ResourceHelper.GetRandomNameFromDatabase(); unit.Name = randomName; } else { unit.Name = UnitName; } UnitManager.Instance.RegisterUnit(unit); nameUnitCanvas.gameObject.SetActive(false); unit.Save(); barracks.CreateUnitEntry(unit); IPayment trainingPayment = new Payment(unit.Role.Name, roleCosts[unit.Role.Name]); resourceManager.MakePayment(trainingPayment); }