You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
713 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class InventoryUI : MonoBehaviour
  5. {
  6. [SerializeField]
  7. private Inventory inventory;
  8. [SerializeField]
  9. private BagItem ItemPrefab;
  10. [SerializeField]
  11. private Transform Parent;
  12. private void Start()
  13. {
  14. UpdateUI();
  15. }
  16. [ContextMenu("Update UI")]
  17. public void UpdateUI()
  18. {
  19. foreach(Transform child in Parent)
  20. Destroy(child.gameObject);
  21. foreach (Inventory.Data data in inventory.BagItems)
  22. {
  23. BagItem item = Instantiate(ItemPrefab.gameObject, Parent).GetComponent<BagItem>();
  24. item.Initialise(data);
  25. }
  26. }
  27. }