public void Load(Tune loadData) { AssembledData = loadData; //Materials for (int i = 0; i < MaterialSlots.Count; i++) { Destroy(MaterialSlots[i].gameObject); } MaterialSlots.Clear(); for (int i = 0; i < AssembledData.CraftMaterials.Count; i++) { CraftMaterialSlot craftMaterialSlot = Instantiate(MaterialSlotTemplate, MaterialTemplate.transform); craftMaterialSlot.gameObject.SetActive(true); craftMaterialSlot.NameInputField.SetTextWithoutNotify(AssembledData.CraftMaterials[i].Name); craftMaterialSlot.AmountInputField.SetTextWithoutNotify(AssembledData.CraftMaterials[i].Amount.ToString()); craftMaterialSlot.GetComponent <RectTransform>().anchoredPosition = new Vector2(MaterialOffset.x, MaterialOffset.y * MaterialSlots.Count); MaterialSlots.Add(craftMaterialSlot); } MaterialAddButton.anchoredPosition = new Vector2(MaterialOffset.x, MaterialOffset.y * MaterialSlots.Count); RecalculateContent(); //Event callback OnRedraw?.Invoke(AssembledData); }
public void AddMaterialSlot() { CraftMaterialSlot craftMaterialSlot = Instantiate(MaterialSlotTemplate, MaterialTemplate.transform); craftMaterialSlot.gameObject.SetActive(true); craftMaterialSlot.GetComponent <RectTransform>().anchoredPosition = new Vector2(MaterialOffset.x, MaterialOffset.y * MaterialSlots.Count); MaterialSlots.Add(craftMaterialSlot); AssembledData.CraftMaterials.Add(new Tune.CraftMaterial()); MaterialAddButton.anchoredPosition = new Vector2(MaterialOffset.x, MaterialOffset.y * MaterialSlots.Count); RecalculateContent(); }