diff --git a/Assets/InventorySlot.prefab b/Assets/InventorySlot.prefab index 238aa03..117099f 100644 --- a/Assets/InventorySlot.prefab +++ b/Assets/InventorySlot.prefab @@ -89,6 +89,7 @@ GameObject: - component: {fileID: 3510585822996971024} - component: {fileID: 3510585822996971026} - component: {fileID: 8059809276634721085} + - component: {fileID: -6709197434562003015} m_Layer: 5 m_Name: InventorySlot m_TagString: Untagged @@ -224,3 +225,29 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: icon: {fileID: 3510585822736120665} +--- !u!61 &-6709197434562003015 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3510585822996971030} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0, y: 0} + oldSize: {x: 0, y: 0} + newSize: {x: 0, y: 0} + adaptiveTilingThreshold: 0 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index deff8b0..c94f7fd 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -1937,7 +1937,7 @@ GameObject: - component: {fileID: 971652022} - component: {fileID: 971652021} m_Layer: 5 - m_Name: Canvas + m_Name: MenuCanvas m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -2719,7 +2719,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9add6f301ddcf864294c3a0e34014b32, type: 3} m_Name: m_EditorClassIdentifier: - menu: {fileID: 1395531174} --- !u!212 &1278234715 SpriteRenderer: m_ObjectHideFlags: 0 @@ -3667,12 +3666,14 @@ MonoBehaviour: m_GameObject: {fileID: 1800469988} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: a6462fee9117d354abebcd1ff897b920, type: 3} + m_Script: {fileID: 11500000, guid: 938a668a83530b74a97d7a3f7eadbc33, type: 3} m_Name: m_EditorClassIdentifier: startItems: - - {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2} - - {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2} + - {fileID: 11400000, guid: d57952ede78a45f4b8b33397f10c7e4d, type: 2} + - {fileID: 11400000, guid: 8fb9ea05ec2c18c4a96f28f9d62da57a, type: 2} + - {fileID: 11400000, guid: 27247f24f52c4dc479e8a654a315a085, type: 2} + - {fileID: 11400000, guid: 1de212a71e25e234da84501ae8430788, type: 2} --- !u!114 &1800469992 MonoBehaviour: m_ObjectHideFlags: 0 @@ -3682,12 +3683,10 @@ MonoBehaviour: m_GameObject: {fileID: 1800469988} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 05183797fdda4aa9ac518eee0d2d85d4, type: 3} + m_Script: {fileID: 11500000, guid: c0102544bd79b724cae037fee2663c8e, type: 3} m_Name: m_EditorClassIdentifier: - allItems: - - {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2} - - {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2} + allItems: [] --- !u!1001 &1805366398 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Inventory.cs b/Assets/Scripts/Inventory.cs index 9b853c3..2f5fe23 100644 --- a/Assets/Scripts/Inventory.cs +++ b/Assets/Scripts/Inventory.cs @@ -43,8 +43,7 @@ public class Inventory : MonoBehaviour { } else { items[item] += amount; } - - + onItemChangedCallback?.Invoke(); } diff --git a/Assets/Scripts/InventorySlot.cs b/Assets/Scripts/InventorySlot.cs index 1949b7d..c45c14e 100644 --- a/Assets/Scripts/InventorySlot.cs +++ b/Assets/Scripts/InventorySlot.cs @@ -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"); + } } \ No newline at end of file diff --git a/Assets/Scripts/InventoryUI.cs b/Assets/Scripts/InventoryUI.cs index 3cdf26c..0608bd9 100644 --- a/Assets/Scripts/InventoryUI.cs +++ b/Assets/Scripts/InventoryUI.cs @@ -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(); - 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 { } } } -} \ No newline at end of file +}