Fix issue with UI container update
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@@ -6,7 +7,7 @@ public class ContainerItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private ContainerSO _containerSO;
|
||||
|
||||
public event EventHandler OnItemsChange;
|
||||
|
||||
private List<BaseItemSO> _items = new List<BaseItemSO>();
|
||||
|
||||
@@ -21,12 +22,27 @@ public class ContainerItem : MonoBehaviour
|
||||
{
|
||||
Debug.Log($"Player put to container a {item.ItemName}");
|
||||
_items.Add(item);
|
||||
OnItemsChange?.Invoke(this,EventArgs.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Container is full");
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(BaseItemSO item)
|
||||
{
|
||||
if (_items.Count>0)
|
||||
{
|
||||
Debug.Log($"Player remove {item.ItemName} from container");
|
||||
_items.Remove(item);
|
||||
OnItemsChange?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Container is emplty");
|
||||
}
|
||||
}
|
||||
|
||||
public List<BaseItemSO> GetItems()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user