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

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Antonio O
Posts: 10
Joined: Wed Apr 18, 2018 6:54 pm

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

Post 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?
User avatar
Tony Li
Posts: 22157
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
Post Reply