Automatically load scriptable object attributes via script?

I’ve been modifying the Coding with Unity Scriptable Object Inventory tutorial project from Youtube. In the tutorial it uses a 3rd person character and a collision to add an item to the inventory(Also a scriptable object). I want to use a loot window style where the items you can pick up are on a canvass/panel. Currently it is giving me a null reference error when I try to add an item as if it cannot find the information from the scriptable object. So I’m taking a different tactic. I want to be able to preload the prefab item with the information. What is the best way to go about this?

This script is going on the prefab.

public class ArmorItem : MonoBehaviour
{
    public Armor ArmorPiece;
    public Item item;
    public Armor Id;
    public Armor Icon;
    public Armor description;
    public Armor weight;
    public Armor value;
    public Armor Prefab;
    public Armor MinProtection;
    public Armor MaxProtection;
    public Armor ArmorPoints;
    public Armor.armorslot  armorSlot;
    public Armor.armorclass armorClass;

    public void GetArmor()
    {
        item.Id = ArmorPiece.Id;
        item.Icon = ArmorPiece.Icon;
        item.type = ArmorPiece.type;
        item.description = BronzeCuriss.description;
        item.value = BronzeCuriss.value;
        item.weight = BronzeCuriss.weight;
        item.Min = BronzeCuriss.MinProtection;
        item.Max = BronzeCuriss.MaxProtection;
        armorSlot = BronzeCuriss.ArmorSlot;
        AP = BronzeCuriss.ArmorPoints;
        armorSlot = BronzeCuriss.ArmorSlot;
    }
    

}

Here is the Armor Scriptable Object:

public class Armor : ItemObject
{
	//ID type(A armor, w weapon, c consumable, g general), class( light, medium, heavy), slot(head, torso, belt, feet, shield), number
	public int MinProtection;
	public int MaxProtection;
	public int ArmorPoints;
	public enum armorslot { Head, Torso, Belt, Feet, Shield }
	public armorslot ArmorSlot;
	public enum armorclass { Light, Medium, Heavy }
	public armorclass ArmorClass;

	private void Awake()
	{
		type = ItemType.Armor;
	}
}

and Finally, the Root script, Item Object

public enum ItemType
{
    Armor,
    Consumable,
    Clothing,
    Beverage,
    Food,
    Pack,
    Herb,
    Tools,
    Light,
    QuestItem,
    Weapon
}


public abstract class ItemObject : ScriptableObject
{
    public int Id;
    public Sprite Icon;
    public ItemType type;
    public string description;
	public int value;
    public int weight;

    public GameObject prefab;

    public Item CreateItem()
    {
        Item newItem = new Item(this);
        return newItem;
    }
}

[System.Serializable]
public class Item
{
    public string Name;
    public int Id;

    public Item(ItemObject item)
    {
        Name = item.name;
        Id = item.Id;


    }

}

I’m still new to scriptable objects and would appreciate some help. Thanks!

Hope this helps you @Gilead7 . What you need to do is create instances of scriptableObject. Then, you create a prefabricated base then you copy it into your project and modify the components as well as the graphics. In prefabs, it will still need to have the ArmorItem script, to which you reference the Item field along with your scriptableObject with the characteristics of the target object. Then you must create a panel so you create an empty gameObject with the CanvasGroup component (whose values ​​you define according to your needs). Then you reference this CanvasGroup to your player’s CanvsGroup variable.

[CreateAssetMenu(fileName = "Item", menuName = "ProjectMenu/Item")]
public class Item : ScriptableObject
{
    public int intExample;
    public float floatExample;
}

public class ArmorItem : MonoBehaviour
{
    public Item item;

    public Player player;
    public int intExample;
    public float floatExample;

    private void Start()
    {
        intExample = item.intExample;
        floatExample = item.floatExample;
    }


}

public class Player : MonoBehaviour
{
    Dictionary<string, ArmorItem> _armorItems;
    public ArmorItem[] armorItems;

    [SerializeField] CanvasGroup canvasGroup;

    private void Start()
    {
        _armorItems = new Dictionary<string, ArmorItem>();
        _armorItems.Values.CopyTo(armorItems, 0);

        foreach (ArmorItem item in armorItems)
        {
            item.transform.SetParent(canvasGroup.transform);
        }
    }

    // Called when the player collects an item.
    public void GetItem(ArmorItem armorItem)
    {
        if (!_armorItems.ContainsKey(armorItem.name))
        {
            _armorItems.Add(armorItem.name, armorItem);
            armorItem.transform.SetParent(canvasGroup.transform);
        }
    }
}