I am trying to add every ScriptableObject i find to a list. The ScriptableObject is called “Items”
EDIT: I already declared itemsList
Here’s my code:
public void loadAllItemsInList() {
itemsList = null;
foreach (Items item in Resources.FindObjectsOfTypeAll(typeof(Items)) as Items[]) {
itemsList.Add(item);
Debug.Log (item.itemName);
}
}
It seems like it should work. But it doesn’t. It just returns an error showing me where i declared my Foreach. And. Saying “Object reference not set to an instance of an object”. No clue how to fix this