I’m working on a project that can cause a loooot of gameobjects to be created. This is perfectly fine until it comes time to close the program, at which point it can hang for upwards of a minute or two while it tries to clear all objects from the scene.
Is there a way to just instantly destroy everything in the same manner that Windows’ ‘End Task’ does to ensure a speedy application close?
Destroy game object when no longer use or use:-
In this method destroy your game objects mannually
Try using object pooling that will help you. If you have repeating objects.
It would be automatically destroyed when you’ll quit the game.
Or Give all objects the same tag.
And paste this code in your Quit Function
Destroy(GameObject.FindGameObjectWithTag("Your Tag Name"));
The problem isn’t in destroying the objects, it’s in the way you use your objects and what you do with them that is slowing down the game when it tries to close.
You should find a way to reduce your total amount of objects in your game.
Perhaps if you can show what your objects are we can provide examples on how to
improve the use of your object usage.