Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
6da7cff68f
5 changed files with 58 additions and 20 deletions
|
|
@ -43,8 +43,7 @@ public class Inventory : MonoBehaviour {
|
|||
} else {
|
||||
items[item] += amount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
onItemChangedCallback?.Invoke();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.PlayerLoop;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class InventorySlot : MonoBehaviour {
|
||||
public Image icon;
|
||||
|
||||
private Item _item;
|
||||
|
||||
private void Start() {
|
||||
Physics.queriesHitTriggers = true;
|
||||
}
|
||||
|
||||
public void AddItem(Item newItem) {
|
||||
_item = newItem;
|
||||
|
||||
|
|
@ -32,4 +37,14 @@ public class InventorySlot : MonoBehaviour {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public void OnMouseOver() {
|
||||
icon.sprite = _item.selectedSprite;
|
||||
Debug.Log("Mouse Over Slot");
|
||||
}
|
||||
//TODO: OnMouse Methods not working :'(
|
||||
public void OnMouseExit() {
|
||||
icon.sprite = _item.defaultSprite;
|
||||
Debug.Log("Mouse Exit Slot");
|
||||
}
|
||||
}
|
||||
|
|
@ -2,33 +2,31 @@ using System.Linq;
|
|||
using UnityEngine;
|
||||
|
||||
public class InventoryUI : MonoBehaviour {
|
||||
|
||||
public Transform itemsParent;
|
||||
public GameObject inventoryUI;
|
||||
private Inventory _inventory;
|
||||
private InventorySlot[] _slots;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start() {
|
||||
_inventory = Inventory.instance;
|
||||
_inventory.onItemChangedCallback += UpdateUI;
|
||||
|
||||
_slots = itemsParent.GetComponentsInChildren<InventorySlot>();
|
||||
toggleInventory();
|
||||
ToggleInventory();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
if(Input.GetButtonDown("Inventory")) {
|
||||
toggleInventory();
|
||||
ToggleInventory();
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleInventory() {
|
||||
|
||||
private void ToggleInventory() {
|
||||
inventoryUI.SetActive(!inventoryUI.activeSelf);
|
||||
}
|
||||
|
||||
|
||||
private void UpdateUI() {
|
||||
for(int i = 0; i < _slots.Length; i++) {
|
||||
if(i < _inventory.items.Count) {
|
||||
|
|
@ -38,4 +36,4 @@ public class InventoryUI : MonoBehaviour {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue