[SOLVED]Loading errors only in Play mode?

EDIT 2: I found the problem. I was calling the return twice, through some terrible coding of callbacks on my part. The variable for the level contents would get set to undefined on the second call, since the second call was trying to load the scene settings instead of the scene objects. I’ve since rewritten my code to only callback once, with the objects from the scene.

I still find it very odd that the editor view had no trouble unloading the previous scene contents, while the game itself would keep them in memory(which with my bad code earlier was the correct behavior). Lesson learned, the editor test run does not equal the Play Button when loading assets. Not sure if that should be counted as a bug or a feature designed to prevent the editor from crashing, getting stuck, or doing dumb things. I will say from my standpoint, it was very annoying, though bad code IS bad code regardless.

Old post content below so this is a bit less confusing if it shows up in search later.

EDIT: Ok, just so everyone knows, I think I found a problem with my loading code and am trying to rewrite it. Now that I look at it, it’s a wonder it worked in editor mode at all. I was forgetting to set some flags for if the resource had been loaded into the scene or not when destroying and creating the scene objects. x_x

Yep, me again. My game content loading works fine in the editor play mode. But in the Play button build, the title screen objects and track level stay loaded. The game does not seem to see them as being loaded correctly when switching scenes(or can’t find them to delete them).

You can see this easily if you open the high scores screen and close it, or try playing the Alpha track. The title screen objects don’t unload properly, and upon viewing the title screen a second time, the game seems to reload the objects again. None of this happens if I go into Edit mode and play the Title scene from inside the editor.

https://playcanvas.com/project/375628/overview/robo-racer

The loading is all managed by this script, part of the main menu system: https://playcanvas.com/editor/code/375628/GUI_version_2_manager.js

I have to get going to do something else this afternoon, and I will take a closer look at my publishing settings and scripts later today.

But I wanted to ask if there was some sort of known “gotchas” with loading scenes/content and publishing builds. I just want to make sure I didn’t miss anything obvious here.

Glad to hear you figured it out.

Not ideal that there are loading differences between editor launches and published builds and we try and keep it to a minimum. But for what it’s worth the main reason for the difference is that we have live connections to the scene and asset data when running from the Editor so that you can update content and see it live update in your game.