the AddToInventory thing needs a argument but i know only 3 arguments non of them is working here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InventorySystem : MonoBehaviour
{
public static InventorySystem Instance { get; set; }
public GameObject inventoryScreenUI;
public bool isOpen;
public List<GameObject> slotList = new List<GameObject>();
public List<string> itemList = new List<string>();
private GameObject itemToAdd;
private GameObject whatSlotToEquip;
//public bool isFull;
private void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
}
else
{
Instance = this;
}
}
void Start()
{
isOpen = false;
PopulateSlotList();
}
// it makes it so i dont need to drag and drop the slots to the slotlist [DOES NOT WORK NOW]
private void PopulateSlotList()
{
foreach (Transform child in inventoryScreenUI.transform)
{
if (child.CompareTag("Slot"))
{
Debug.Log("slotlist is working");
slotList.Add(child.gameObject);
}
}
}
// makes it so i can open the inventory
void Update()
{
if (Input.GetKeyDown(KeyCode.E) && !isOpen)
{
Debug.Log("E is pressed");
Cursor.lockState = CursorLockMode.None;
inventoryScreenUI.SetActive(true);
isOpen = true;
}
else (Input.GetKeyDown(KeyCode.E) && isOpen);
{
Cursor.lockState = CursorLockMode.Locked;
inventoryScreenUI.SetActive(false);
isOpen = false;
}
AddToInventory(,itemName);
{
isFull = true;
Debug.Log("inventory is full");
whatSlotToEquip = FindNextEmptySlot();
itemToAdd = Instantiate(Resources.Load<GameObject>(itemName), whatSlotToEquip.transform.position, whatSlotToEquip.transform.rotation);
itemToAdd.transform.SetParent(whatSlotToEquip.transform);
itemList.Add(itemName);
}
}
public bool CheckIsFull()
{
isFull =true;
int counter = 0;
foreach (GameObject slot in slotList)
{
if (slot.transform.childCount >0)
{
counter == 1;
}
}
if (counter == 21)
{
return true;
}
else
{
return false;
}
}
private GameObject FindNextEmptySlot()
{
foreach(GameObject slot in slotList)
{
Debug.Log("2");
if (slot.transform.childCount == 0)
{
Debug.Log("working 2");
return slot;
}
}
return new GameObject();
}
}