0
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PickUp : MonoBehaviour
{
    private Inventory inventory;
    public GameObject itemButton;
    private void Start()
    {
        inventory = GameObject.FindGameObjectWithTag("Die").GetComponent<Inventory>();
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.CompareTag("Die"))
        {
        
            for (int i = 0; i < inventory.slots.Length; i++)
            {
          
                if(inventory.isFull[i] == false)
                {
                
                    inventory.gameObject.GetComponent<DisplayInventory>().icon.SetActive(true);
                    inventory.isFull[i] = true;
                    Instantiate(itemButton, inventory.slots[i].transform);

                
                    //Destroy(gameObject);
                    return;
                }
           
            }
        }
    }

}

Whenever I collect an object it is destroyed and added in my scriptable object inventory and when I collect second object it doesn't get count in my inventory. Thankyou in Advance

0 Answers0