- Home /
I fixed it.
Object not existing after reloading scene (nullreferenceexception)
I'm having an issue when I reload my scene with my variable not existing. I have an Inventory object class:
public class Inventory {
and I make an inventory in my player script.
public Inventory pInv;
and I set it in the start function.
pInv = new Inventory (10, 50);
It works fine at the when I first load the scene, but when I reload the scene, I get a nullreferenceexception when trying to access it. I also get ONE missingreferenceexception when the reloaded scene starts. I have no idea why this is happening.
I fixed it, kind of. I just changed the Inventory to being a monobehaviour and am doing it that way. Works so far.
Answer by watercat · Feb 06, 2018 at 03:55 PM
download this https://assetstore.unity.com/packages/tools/utilities/scene-streamer-38168
Hope it helps
I’m not trying to use this data persitistence at the moment, I’m just reloading the scene, everything else is reset, but the inventory isn’t being created for some reason.
Follow this Question
Related Questions
NullReferenceException - When destroying Object 1 Answer
Multiple Cars not working 1 Answer
Object reference not set to an instance of an object... 0 Answers
Unknown reason for NullReferenceException error 1 Answer
Distribute terrain in zones 3 Answers