Hello,
I was trying to build my game today, but my built game is completely broken. The screen is black, the music doesn’t play, nothing happens when I press keys…
After some research I finally found where the problem comes from : it seems as if ALL my variables set from the inspector for ALL of my scripts simply disappear when I build my project ! Nothing works because all of my variables are empty.
- when I play my game in Unity, everything works fine
- when I launch my PC built game and I record logs, I can see “NullReferenceException: Object reference not set to an instance of an object” splattered everywhere in the logs…
I’ve never heard of any bug like this… Any idea is welcome !
Update :
Well… I did make a debugging build with breaking points and made some progress :
It looks like my variables are not disappearing, there are just… stuck with old values ? I can recognise values from my previous build (2 month ago). Is it possible for the variables to retain values from previous build even though I changed them in the editor ?
That would explain why the variables I added very recently are empty and cause NullReferenceException → they did not existed in my previous build !
For some more info :
-
I’m using Unity 2020.3, I tried opening and building my project with Unity 2022.3 → same bug
-
I tried Assets > Reimport all → same bug
-
My project is fairly small, I only have one scene
-
I tried creating test variables with different types, but everything comes out as empty variables in my build (booleans, strings, custom class instances, everything !!!)
-
I’m using Github even though I work alone. I saw somewhere that assets references can break if you switch branches. But I reimported everything and it did not solve my bug…