Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Zaeran · Feb 02, 2020 at 04:27 PM · optimisation

Destroying GameObjects instantly when quitting

Hey folks!

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?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sacredgeometry · Feb 02, 2020 at 06:01 PM 0
Share

When you say a lot how much is a lot? Do you have code in those objects destructors/OnDestroy $$anonymous$$ethods?

avatar image Zaeran sacredgeometry · Feb 03, 2020 at 11:36 AM 0
Share

Can be in the thousands. There's some code in OnDestroy, but nothing major.

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Nk_Khumbhani · Feb 03, 2020 at 12:17 PM

Destroy game object when no longer use or use:-

void OnDestroy() { Debug.Log("OnDestroy"); }

In this method destroy your game objects mannually

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Zaeran · Feb 04, 2020 at 02:24 AM 0
Share

Not what I'm after I'm afraid. Destroying objects isn't the problem, it's the time taken to remove them all when quitting the application

avatar image
0

Answer by joker_yash96 · Feb 03, 2020 at 12:32 PM

Try using object pooling that will help you. If you have repeating objects.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Zaeran · Feb 04, 2020 at 02:25 AM 0
Share

Pooling doesn't help with the destroy time unfortunately

avatar image joker_yash96 Zaeran · Feb 04, 2020 at 05:13 AM 0
Share

Btw why are you trying to destroy the objects when Game Quits?

avatar image Zaeran joker_yash96 · Feb 16, 2020 at 11:08 PM 0
Share

I'm not. Unity is automatically

avatar image
0

Answer by haseeb5639 · Feb 04, 2020 at 05:23 AM

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"));

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Zaeran · Feb 16, 2020 at 11:16 PM 0
Share

The problem isn't that I need to destroy all objects. It's that all the objects automatically being destroyed when Unity quits cause the software to hang.

Trying to see if there's a way to have them all be destroyed instantly and essentially force closing the software ins$$anonymous$$d of having to wait for them all to be destroyed

avatar image
0

Answer by ShadyProductions · Feb 04, 2020 at 12:04 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Zaeran · Feb 16, 2020 at 11:09 PM 0
Share

It's a map creation tool for tabletop games, so there's no way to reduce the number of objects.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

120 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

iphone built quality setting 1 Answer

Huge Nebula & Asteroid Field 0 Answers

Implementation of directional buildings? 1 Answer

Shader.WarmupAllShaders ? What it does? 0 Answers

(Oculus Rift) Spikes in “GPU Usage – Other” causing frame freezes. Can I avoid this? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges