Hi, i have some questions and problems about inventory system in unity. First of all, i created some sort of inventory using youtube channels but, when i pick one item two times, it will take two slots as well. For example, if i pick Two swords, it will take two slots but i don’t like it this way. can someone help me? i have this pickup code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pickup : MonoBehaviour
{
private Inventory inventory;
private InventoryTwo invenven;
public GameObject itemButton;
void Start()
{
inventory = GameObject.FindGameObjectWithTag("Player").GetComponent<Inventory>();
invenven = GameObject.FindGameObjectWithTag("Player").GetComponent<InventoryTwo>();
}
void OnTriggerEnter2D(Collider2D Other)
{
if (Other.CompareTag("Player"))
{
for (int i = 0; i < inventory.slots.Length; i++)
{
if (inventory.isFull[i] == false)
{
inventory.isFull[i] = true;
Instantiate(itemButton, inventory.slots[i].transform, false);
Destroy(gameObject);
break;
}
}
}
if (Other.CompareTag("Player"))
{
for (int i = 0; i < invenven.slots.Length; i++)
{
if (invenven.isFull[i] == false)
{
invenven.isFull[i] = true;
Instantiate(itemButton, invenven.slots[i].transform, false);
Destroy(gameObject);
break;
}
}
}
}
}
My second question is that how can i make a select part for these. for exampe, if I Scroll down to First slot, my character pick the Item that is in it? like stardew valley!