I have a class that is supposed to be a repository for all my game’s items and many other things. This repository has a static list called equipment. When creating UI I can easily use foreach on that list, but when I try to reference specific object, or reference by index, it always returns null. Even within that repo class, one line after. Does anyone know what’s going on? And how can I fix that?
Here’s the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts
{
public class StuffRepo:MonoBehaviour
{
private static StuffRepo instance;
public static List<Item> equipment;
private void Awake()
{
instance = this;
equipment = new List<Item>();
equipment.Add(new Item("Stuff", "desc.", 1, 1));
equipment.Add(new Item("OtherStuff", "desc2", 2, 3));
}
}
}