using UnityEngine;


[CreateAssetMenu(fileName = "New Item", menuName = "Inventory/Item")]

[System.Serializable]

public class Item : ScriptableObject {


    new public string name = "New Item";

    public Sprite icon = null;

    public bool isDefaultItem = false;

    public int ID;

    public int itemAmount = 0;



    public virtual void Use ()

    {

       //Something Use

    }


    public void RemoveFromInventory()

    {

        Inventory.instance.Remove(this);

    }

}


이게 스크립터블 아이템 오브젝트

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

[System.Serializable]
public class Inventory : MonoBehaviour
{

    #region Singleton

    public static Inventory instance;

    private void Awake()
    {
        if (instance != null)
        {
            Debug.LogWarning("More than one instance of Inventory found!");
            return;
        }

        instance = this;
    }

    #endregion
   
    public delegate void OnItemChanged();
    public OnItemChanged onItemChangedCallback;
    public int space = 6;

    public static List<Item> inventory = new List<Item>();
    
    public List<Item> items = new List<Item>();

    public void InventorySaved()
    {
        BinaryFormatter bf = new BinaryFormatter();
        FileStream fs = File.Create(Application.persistentDataPath + "/Inventory.dat");
        List<int> saveId = new List<int>();

        saveId = items[0].ID; // 오류 부분

        bf.Serialize(fs.saveId);
        fs.Close();

        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }
    }
    public void InventoryLoaded()
    {
        if(File.Exists(Application.persistentDataPath + "/Inventory.dat"))
        {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream fs = File.Open(Application.persistentDataPath + "/Inventory.dat", FileMode.Open);

            List<int> loadId = (List<int>)bf.Deserialize(fs);
            fs.Close();
        }

        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }
    }

/* 세이브/로드와 무관
    public void Add(Item item)
    {
        if (!item.isDefaultItem)
        {
            if (items.Count >= space)
            {
                Debug.Log("Not enough room.");
                return;
            }

            items.Add(item);
            item.itemAmount++;

            if (onItemChangedCallback != null)
            {
                onItemChangedCallback.Invoke();
            }
        }
    }

    public void Remove(Item item)
    {
        items.Remove(item);
        item.itemAmount--;

        if (onItemChangedCallback != null)
        {
            onItemChangedCallback.Invoke();
        }
    }

    public bool CheckForItem(Item item)
    {
        if (items.Contains(item))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public bool InventoryCheck(Item item)
    {
        if(items.Contains(item))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

   public void InventoryReset()
    {
        inventory.Clear();
    }

    public void ItemAmountReset()
    {
        for(int i = 0; i<items.Count; i++)
        {
            items[i].itemAmount = 0;
        }
    }
} */

나도 튜토리얼보고 따라하는 따라쟁이 수준이라서 굉장히 못해. 직접 코드 따는 프로그래머가 아닌 빼끼는 코더 수준이니까.
그래서 일주일째 인벤토리로 헤매고 있음. 안개속에서 헤엄치는 기분이랄까.
인벤토리 세이브/로드 기능이 제일 큰 난관이다 ㅠ..
다음 게임은 기본 클래스에 넣던가해야지..