weighted inventory system

[CreateAssetMenu(fileName = “Item”)]

public class Item : ScriptableObject
{
[Header(“ItemStats”)]
//name
public string itemName;
//icon
public Sprite Icon;
//item description
public string itemDescription;
//Id
public int itemID;
//Weight
public float weight;

public float Weight
{
get { return weight; }
set { weight = value; }
}
}

public class Inventory : MonoBehaviour

{
[SerializeField] List items;
[SerializeField] Transform itemsParent;
[SerializeField] ItemSlot itemSlots;
public Item item;
public float currentweight = 0;
public float totalweight = 100;

private void RefreshUI()
{
    int i = 0;
    for(; i < items.Count && i < itemSlots.Length; i++)
    {
        itemSlots_.item = items*;*_

currentweight += item.weight;
}
for(; i < itemSlots.Length; i++)
{
itemSlots*.item = null;*
}
}
}
I’m trying to add a weight system to my inventory like fallout but it just take information from my one scriptable object rather than the item in the slot. How can I make the script read the item in slots indivisual rather than setting a value for all items.

hello @jonathanbooker2911, first just an advice if you are creating a property Weight for returning weight, mark weight as private since having both accesible when both are the same var it is a bit confusing. you are adding item.weight (not sure if you assigned that var in the editor) just change

currentweight += item.weight;

to

currentweight += itemSlots*.item.Weight;*
hope it helps.