public void Load(LevelObject levelObject) { this.levelObject = levelObject; LevelIcon.sprite = levelObject.Ico; MapName.text = levelObject.LevelInfo.LevelName; RecomendedLevel.text = levelObject.LevelInfo.RecomendedLevel; Description.text = levelObject.LevelInfo.LevelDiscription; List <unitCategory> unitsCategory = new List <unitCategory>(); foreach (UnitObject unit in levelObject.Units) { bool haveCategory = false; foreach (unitCategory ct in unitsCategory) { if (unit == ct.unitImage) { haveCategory = true; ct.number++; } } if (!haveCategory) { unitsCategory.Add(new unitCategory(unit)); } } if (UnitParent.childCount > 0) { for (int i = 0; i < UnitParent.childCount; i++) { Destroy(UnitParent.GetChild(i).gameObject); } } foreach (unitCategory uc in unitsCategory) { UnitInfo unitInfo = Instantiate <UnitInfo>(UnitPrefab, UnitParent); unitInfo.Load(uc.unitImage, uc.number); unitInfo.GetComponent <Button>().onClick.AddListener(() => LoadUnitInfo(uc.unitImage)); unitInfo.GetComponent <Button>().onClick.AddListener(() => OnClickAction.Invoke()); } }