- Home /
Scene Null Reference in build
Hello there!
I am making a platformer game and I want to make a streaming world. I made some simple empty game objects with a box collider 2D that act as a trigger for when to load a new section and unload an old one. I've created a public Object field for them and I drop and drag the scene I want to load/unload on top of them. Afterwards, the script loads / unloads the scene via the scene manager Async functions. It works absolutely perfectly in the editor, but when I build it it gives me a null reference exception when it tries to access that Scene Object file I dropped in the inspector and nothing loads.
My general guess is that something happens to the Scene file on build and it becomes unaccessible in the same way that other objects are accessible. I would greatly appreciate any input! =)
Answer by Glurth · Apr 24, 2018 at 05:07 PM
Not ALL scene are automatically included in the output build. You should add all the scene that MIGHT be used into the build settings. I suspect you currently have the build settings configured with only the initial scene it should open.
I have all the scenes that I should in the build settings, the problem was that for some reason the Scenes ASSETS aren't included in the build, so that's why there's a null reference exception. The scenes are still included somehow, but not as a directly referenceable objects. $$anonymous$$y solution was to make a simple script that takes the Scene file references in the editor and transforms them into a string variable, which gets included in the build and is accessible and there are no issues whatsoever :)
could you please share a link to the mentioned "$$anonymous""y solution?