void Awake(){ splitButton.onClick.AddListener (delegate { Troop troop=null; if (selectedUnit.location==TroopLocation.BARRACKS){ troop = GameManager.instance.CurrentGame.barracksUnits; } else if (selectedUnit.location==TroopLocation.PLAYER){ troop = GameManager.instance.CurrentGame.playerTroop; } for (int i=0; i<troop.units.Count; ++i){ if (troop.units[i]==null){ troop.AddUnits(unit, (-1)*(int)slider.value, selectedUnit.index); Unit newUnit = unit.GetDublicate(); newUnit.amount=(int)slider.value; troop.AddUnits(newUnit, newUnit.amount, i); break; } } GuiManager.instance.SelectUnit(-1, TroopLocation.NULL, true); gameObject.SetActive(false); }); }