I not understand why ScriptableObject produce this(I need help )

Hi, I need help with this X.x

why when i use a ScriptableObject here

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Equipment : Item//(item is a scriptableObject) {

        public EquipmentSlot equipSlot;

        public override void Use()
        {
            base.Use ();
            EquipmentManager.instance.Equip (this);
        }
    }

    public enum EquipmentSlot{Head, Chest, Legs, Weapon, Shield, Feet}

This code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EquipmentManager : MonoBehaviour {

    #region Singleton
    public static EquipmentManager instance;

    void Awake()
    {
        instance = this;
    }
    #endregion

    Equipment[] currentEquipment;

    void Start()
    {
        int numSlots = System.Enum.GetNames(typeof(EquipmentSlot)).Length;
        currentEquipment = new Equipment[numSlots];
    }

    public void Equip(Equipment newItem)
    {
        int slotIndex = (int)newItem.equipSlot;
    }
}

Shows this:

And when i use my Item Script(this is in a database):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(menuName = "Inventory System/Database")]
public class Database : ScriptableObject {
    public List<Item> items = new List<Item>();

    public  Item FindItemInDatabase(int id)
    {
        foreach (Item item in items)
        {
            if (item.id == id)
            {
                return item;
            }
        }
        return null;
    }

    public Item FindItemPrefab(string name)
    {
        foreach (Item item in items)
        {
            if (item.prefab.ToString () == name)
            {
                return item;
            }
        }
        return null;
    }
}


[System.Serializable]
public class Item
{
    public int id;
    public GameObject prefab;
    public string name;
    [TextArea(5,5)]
    public string description;
    public bool isStackable;
    public ItemType itemType;
    public Stats stats;
    public Vector2 scrollPos;
    public Sprite itemImage;
    [System.Serializable]
    public struct Stats
    {
        public int cost;
        public int sellCost;     
        public int damage;
        public int defense;
        public int health;
        public int mana;
    }
    public enum ItemType {CONSUMABLE, WEAPON, CLOTH, QUEST, MISC}

    public virtual void Use()
    {
        Debug.Log ("Using:'" + name);
    }
}

the Inspector shows this:

PD: I’m following a YT tutorial, I’m new in this C:

Turn off Debug Mode first off, in the little gear icon menu in the top right of any component in the inspector. It’s confusing the issue. Also, you never actually said what the problem is that you’re trying to solve, which is making me have to make guesses here. we’re not going to sit through a lengthy tutorial to see what the result is supposed to be, you have to tell us.

The main problem may be that “currentEquipment” in the EquipmentManager is private by default, so you need to make it public or add the SerializeField attribute to it so it’ll display in the inspector. That’s if the currentEquipment displaying and being editable in the inspector is your problem.

There’s a note that says “Item is a ScriptableObject”, but in the scripts below it’s actually not. The database holding “items” is, but Item is not. If you want to be able to make Items individually and drag and drop them around in the inspector, it really does need to derive from ScriptableObject and have a CreateAssetMenu attribute attached so you can make new ones in the project files using the right click → Create menu.

It’s worth noting that the list of Items in the database probably won’t retain their specific type information without the Item class deriving from ScriptableObject. What this means is that the list of items will look and work fine, equipment you add will be equipment, and other types derived from Item will be their own respective types, until you restart Unity. At that point, the ScriptableObject will reload its data from the file, and all sub-type data will be lost- any data specific to items as Equipment will be gone, because the List is of type “Item”, not of type “Equipment”. The best way to solve this is to make Item, and its derived types, be ScriptableObjects. This way, the items are stored in their own individual files, not just in an “Item” collection, so they’ll retain their specific types just fine between sessions.

yeah sorry i change it. I was using other script named “Item1” instead “Item”, Item1 was the ScriptableObject, my main problem is when i change Item(the script in database) to ScriptableObject in database (item : ScriptbleObject) I get a lot of error X.x and this depress me xDD
later i will reviw this of currentEquipment, now I’m out of my house.
Thanks for you answer and sorry for my bad english :confused: