did i really spend less than an hour working on this game over the course of an entire week? yes!
This commit is contained in:
parent
b842289076
commit
4a80a6ed0f
10 changed files with 113 additions and 1 deletions
26
Assets/Scripts/Inventory/CraftableUIObject.cs
Normal file
26
Assets/Scripts/Inventory/CraftableUIObject.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CraftableUIObject : MonoBehaviour
|
||||
{
|
||||
public CraftingRequirementUIObject templateRequirementUI;
|
||||
public Transform requirementGrid;
|
||||
public TextMeshProUGUI itemNameText;
|
||||
public TextMeshProUGUI amountText;
|
||||
public Image itemIcon;
|
||||
public Button thisButton;
|
||||
|
||||
public void SetObject(Item itemToSet)
|
||||
{
|
||||
itemNameText.text = itemToSet.itemName; //it would be reset every time you open the inventory instead of updating only the amount but whatever it doesn't matter
|
||||
amountText.text = $"x{itemToSet.craftedAmount}";
|
||||
itemIcon.sprite = itemToSet.icon;
|
||||
thisButton.onClick.AddListener(() => CraftingSystem.instance.TryCraftingItem(itemToSet));
|
||||
foreach (InventoryManager.ItemAmount craftingRequirement in itemToSet.requiredMaterials)
|
||||
{
|
||||
CraftingRequirementUIObject newRequirementUI = Instantiate(templateRequirementUI, requirementGrid);
|
||||
newRequirementUI.SetObject(craftingRequirement.item, craftingRequirement.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue