Hi! I might have to apologize for the dumb question but I don’t really understand why I get this error. Every time I load a shop in my game it gives me an error:
NullReferenceException: Object reference not set to an instance of an object
ShopController.IsItemBought (SpellPattern spell) (at Assets/Scripts/Unity/ShopController.cs:13)
ShopItem.Start () (at Assets/Scripts/Unity/ShopItem.cs:43)
here’s ShopController.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShopController : PSingleton<ShopController>
{
private List<SpellPattern> m_boughtSpells = new List<SpellPattern>();
public bool IsItemBought(SpellPattern spell)
{
foreach(var el in m_boughtSpells)
{
if (el.Equals(spell))
{
return true;
}
}
return false;
}
public void AddNewBoughtItem(SpellPattern item)
{
if (!m_boughtSpells.Contains(item))
{
m_boughtSpells.Add(item);
GameManager.Instance.SaveGame();
GameManager.Instance.LoadGame();
}
}
protected override void Load()
{
m_boughtSpells = gameData.boughtSpells;
}
protected override void Save()
{
gameData.boughtSpells = m_boughtSpells;
}
}
and here’s start void from ShopItem.cs
private void Start()
{
anim = tutorialPointer.GetComponent<Animation>();
isBought = ShopController.Instance.IsItemBought(spellPattern);
}