projectEli/Assets/SimpleInventorySystem/Scripts/UI/GroupSlotUI.cs

84 lines
2.0 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace SimpleInventorySystem
{
public class GroupSlotUI : MonoBehaviour
{
public SlotUI slot;
//public SlotUI[] attachmentsSlots;
// public GridUI grid;
private ItemUI item;
public GameObject[] uiContainerGameObjects;
// Start is called before the first frame update
void Start()
{
if(slot != null)
{
item = slot.GetItemUI();
slot.groupSlot = this;
}
}
private void ChangeGridSize()
{
if(item == null)
{
Debug.LogError("GroupSlotUI: ItemUI item cannot be null.");
return;
}
if (item.ContainedItems == null)
{
Debug.LogError("GroupSlotUI: ItemUI must be a container. i.e. It has an initialized ContainedItems object.");
return;
}
//grid.ChangeGridLayoutSize(item.containerSize.Height, item.containerSize.Width);
}
public ItemUI GetItemUI()
{
item = slot.GetItemUI();
return slot.GetItemUI();
}
public void ShowUIContainer()
{
foreach(GameObject uiContainerGameObject in uiContainerGameObjects)
{
uiContainerGameObject.SetActive(true);
}
}
public void HideUIContainer()
{
foreach (GameObject uiContainerGameObject in uiContainerGameObjects)
{
uiContainerGameObject.SetActive(false);
}
}
// Update is called once per frame
void Update()
{
}
internal void OnItemDropped()
{
item = slot.GetItemUI();
//ChangeGridSize();
ShowUIContainer();
}
internal void OnItemRemoved()
{
item = null;
HideUIContainer();
}
}
}