::
I got this error when adding new weapon:
NullReferenceException: Object reference not set to an instance of an object
InventoryManager.AddWeapon (System.Int32 slotIndex, WeaponController weapon) (at Assets/Script/Player/InventoryManager.cs:51)
PlayerStats.SpawnWeapon (UnityEngine.GameObject weapon) (at Assets/Script/Player/PlayerStats.cs:325)
InventoryManager+<>c__DisplayClass18_0.<ApplyUpgradeOptions>b__0 () (at Assets/Script/Player/InventoryManager.cs:153)
Level up weapon, adding new passive item and level up passive item work fine but i got that error choosing new weapon.
The errors point at
InventoryManager
weaponLevels[slotIndex] = weapon.weaponData.Level;
PlayerStat
inventory.AddWeapon(weaponIndex, spawnedWeapon.GetComponent<WeaponController>()); // Add weapon to its inventory slot
InventoryManager
upgradeOption.upgradeButton.onClick.AddListener(() => player.SpawnWeapon(chosenWeaponUpgrade.initialWeapon)); //Apply the button functionality