Page 1 of 1

Destroy messages when changing Scene

Posted: Fri Aug 24, 2018 6:41 pm
by nathanj
Hi Tony

I've recently began modifying our game to support multi scene changes while having the DS manager persistent.

I've been getting some error messages when the scene changes, they're like this:

Code: Select all

Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
The following scene GameObjects were found:
Camera(Clone)
There were more like this, often referencing Text Mesh Pro components (my DS UI uses TMP components), but I forgot to copy those (I'm writing this message away from my work computer).

Also, I'm using Cinemachine and it doesn't seem to support mulitscene workflows, i.e. the camera brain needs to be generated on scene start with the virtual cameras it will connect to. The problem with this is that when I trigger a scene change from a Dialogue System Trigger through the LoadLevel Sequencer command I get an error like above that a main camera was not found in the scene (because it was destroyed on scene change)and it generates a Sequencer camera. It then generates a message, like above, that the Sequencer camera could not be "cleaned up properly". It seems to cause an issue as well with the main camera from the entered scene as the Sequencer Camera is registered as the Main Camera and overrides the existing Camera with the Camera Brain. Does this make sense? I seem to have resolved this one issue by putting a camera in the DS manager, disabling it and connecting it to the camera input slot located in the camera tab of the Dialogue System Manager component. Like I said, this seems to resolve the issue but it's a little messy. Is it because there are no cameras found in the scene when the command it run from the DS Sequencer?Again, I hope this all makes sense.

Anyways, I'm wondering if you've seen anything like this and if so do you have any suggestions for how to resolve it? Or, if you need me to clarify anything just let me know.

Thanks in advance.

Nathan

Re: Destroy messages when changing Scene

Posted: Fri Aug 24, 2018 9:13 pm
by Tony Li
Hi Nathan,

I think you accurately narrowed down the problem. Given the restrictions of Cinemachine, I think that's what you'll need to do. You can try adding a Don't Destroy GameObject component to the sequencer camera so it will survive the scene change.