private void PopulateSkillsMenu(List <Ability> abilities) { int menuPosition = 1; foreach (Ability ability in abilities) { SkillsMenuButton.Create(this, ability.Name(), menuPosition); menuPosition += 1; } }
public static SkillsMenuButton Create(BattleMenu parentMenu, string abilityName, int position) { GameObject skillsMenuButton = Instantiate((GameObject)Resources.Load(string.Format("Prefabs/Battle/UI/SkillsMenuButton")), new Vector3(0.0f, -50.0f * position, 0.0f), Quaternion.identity); skillsMenuButton.transform.SetParent(parentMenu.skillsMenu.transform.Find("SkillsContainer").transform, false); SkillsMenuButton menuButtonScript = skillsMenuButton.GetComponent <SkillsMenuButton>(); menuButtonScript.text = skillsMenuButton.GetComponentInChildren <Text>(); menuButtonScript.text.text = abilityName; menuButtonScript.button = skillsMenuButton.GetComponentInChildren <Button>(); menuButtonScript.button.onClick.AddListener(delegate { parentMenu.SkillSelected(abilityName); }); return(menuButtonScript); }