private void InstantiateSecondCamp(List <int> skills) { string jsonFile = Resources.Load <TextAsset>("Json/SkillInfoJson").ToString(); SkillInfoJsonArray skillInfos = JsonUtility.FromJson <SkillInfoJsonArray>(jsonFile); float offset = 100f; for (int i = 0; i < skills.Count; i++) { SkillInfoJson skill = skillInfos.skillInfo[skills[i]]; GameObject selectedSkill = Instantiate(secondCampSkillPrefab, secondCampPanel); selectedSkill.GetComponent <LoadingSkill>().Initialize(true, skill.skillName, Resources.Load <Sprite>(skill.skillImagePath)); selectedSkill.GetComponent <RectTransform>().anchoredPosition = -new Vector2(0, offset + i * selectedSkill.GetComponent <RectTransform>().sizeDelta.y); } }
private void InstantiateSkillButton() { string jsonFile = Resources.Load <TextAsset>("Json/SkillInfoJson").ToString(); skill = JsonUtility.FromJson <SkillInfoJsonArray>(jsonFile); int rowCnt = 5; for (int i = 0; i < 20; i++) { GameObject skillButton = Instantiate(skillButtonPrefab, skillPanel); RectTransform rect = skillButton.GetComponent <RectTransform>(); Vector2 spawnPos = new Vector2((i % rowCnt) * rect.sizeDelta.x, -(i / rowCnt) * rect.sizeDelta.y); rect.anchoredPosition = spawnPos; skillButton.GetComponent <SkillButton>().Initialize(this, i, Resources.Load <Sprite>(skill.skillInfo[i].skillImagePath)); skillButtons.Add(skillButton.GetComponent <SkillButton>()); } }