public void ChangeCategoryUI(bool toLeft) { if (toLeft) { CategoryPos--; } else { CategoryPos++; } if (CategoryPos == -1) { CategoryPos = 1; } if (CategoryPos == 2) { CategoryPos = 0; } PlayerSkillCa = (PlayerSkillCategory)CategoryPos; CategoryText.text = PlayerSkillCa.ToString(); GenerateSkillIcons(PlayerSkillCa); }
// public Transform ItemScroll; public void GenerateSkillIcons(PlayerSkillCategory category) { for (int i = SkillScroll.childCount - 1; i >= 0; i--) { Destroy(SkillScroll.GetChild(i).gameObject); } //for(int j = ItemScroll.childCount-1; j >= 0; j--) //{ // Destroy(ItemScroll.GetChild(j).gameObject); //} foreach (PlayerActiveSkill skill in SkillManager.Instance.PlayerActSkills) { if (skill.Category == category) { GameObject go = Instantiate(SkillIconObj); go.transform.SetParent(SkillScroll); //go.transform.SetParent(ItemScroll); go.GetComponent <Image>().sprite = skill.SkillIcon; go.GetComponentInChildren <Text>().text = skill.Name; if (CategoryText.text != "Equipment") { go.AddComponent <ImgDrag>(); } go.AddComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll; go.AddComponent <BoxCollider2D>().size = new Vector2(40, 40); go.GetComponent <Button>().onClick.AddListener(() => SkillBtnPressed(go.GetComponent <Button>())); } } }