Page 1 of 1

Some objects were not cleaned up when closing the scene. Bug?

Posted: Wed Apr 18, 2018 7:06 pm
by Antonio O
I just implement this in tool in my game, and I noticed that resetting a level cause the following error:
Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
I keep getting this error every time I reset the game, is not always, but 1 every 3 times I reset a scene. It's only happening if I don't have the "Destroy On Load" tick. The reason why we want that is because, if the player resets the level we want to reset the dialog and dialogs are quest dependent. I'm not sure if its a bug, or what, any suggestions?

Re: Some objects were not cleaned up when closing the scene. Bug?

Posted: Wed Apr 18, 2018 7:44 pm
by Tony Li
Hi,

Thanks for using the Dialogue System! When reloading a level, use the LevelManager component, for example:

Code: Select all

FindObjectOfType<PixelCrushers.DialogueSystem.LevelManager>().LoadLevel("my level");
or, since you're not keeping the Dialogue Manager, call PersistentDataManager.LevelWillBeUnloaded to tell components such as PersistentDestructible and IncrementOnDestroy that they're being destroyed because the level is being unloaded:

Code: Select all

PixelCrushers.DialogueSystem.PersistentDataManager.LevelWillBeUnloaded();
Also, if you're using IncrementOnDestroy and you're using version 1.8.0 or earlier, please download an updated copy of the script from the Dialogue System Extras page. Under "Updated Support Packages", expand the 1.8.0 or 1.7.7.3 foldout and download the package. It's the same package for both foldouts.