I am able to add items to normal inventories fine, but every time I try to add them to my shop inventory i get this null reference error.
My code...
My Error...
Is there something specific I need to type when adding items to a shop inventory?
My code...
Code:
if (itemAmount > 0)
{
var item = InventorySystemManager.GetItem(2405331441);
var _state = item.GetAttribute<Attribute<int>>("State").GetValue();
if (_state == 1)
{
m_Inventory.RemoveItem("Hoe", itemAmount);
// m_Morge.AddItem("Hoe", 1); // This line of code goes to a normal storage and works fine
m_MACS.AddItem("Hoe", 1); // This line of code references a shop inventory and give me the error
var newItem = InventorySystemManager.CreateItem(keyItemDefinition);
var itemInfo = new ItemInfo((1, newItem));
var _sprite1 = itemInfo.Item.GetAttribute<Attribute<Sprite>>("Icon1").GetValue();
var _sprite = itemInfo.Item.GetAttribute<Attribute<Sprite>>("Icon");
var _state_ = itemInfo.Item.GetAttribute<Attribute<int>>("State");
_sprite.SetOverrideValue(_sprite1);
_state_.SetOverrideValue(0);
}
}
My Error...
Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory.get_MainItemCollection () (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/InventoryCollections/Inventory.cs:257)
Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory.AddItem (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, Opsive.UltimateInventorySystem.Core.DataStructures.ItemStack stackTarget) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/InventoryCollections/Inventory.cs:460)
Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory.AddItem (System.String itemName, System.Int32 amount) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/InventoryCollections/Inventory.cs:507)
Clock.Reset () (at Assets/Scripts/Clock.cs:325)
Clock.Update () (at Assets/Scripts/Clock.cs:59)
Is there something specific I need to type when adding items to a shop inventory?