Profile cover photo
Profile photo
Alan Wood
25 followers -
Game Developer @ StepWood Productions, LLC
Game Developer @ StepWood Productions, LLC

25 followers
About
Alan's posts

Post has attachment

How does one control the ordering of MonoBehaviour.Destroy()?

I have a game object that represents an object factory. In debug mode, it tracks allocations and deallocations. This works great until I try to stop play mode in the editor. The factory game object is destroyed before the other game objects and reports missing deallocations. Then the other objects destroy and report incorrect deallocations.

I tried script execution order, but that doesn't seem to order destroys.

I know I could put a hard link between the game objects such that if the factory object is destroyed, it destroys the other objects. However I'd prefer to delay the destruction of my factory until it is "the last object".

This will likely be an issue for me between level loads as well, so a solution that only works at exit wont do.

Starting a coroutine in destroy appears to be an unsupported pattern as well.

Any ideas?
Wait while more posts are being loaded