Is it possible to stop the destruction of a gameObject after Destroy(SomeGameObject) has been performed? I know that the destruction doesn't actually take place until the Update phase of the Unity thread has been completed, so I was hoping there would be a way to remove my gameobject from whatever destruction queue Unity saves them gameobjects to.
Answer by Benproductions1
Jun 29, 2013 at 03:03 AM
You can't. What you are asking is simply not possible.But you can work around the problem. Plenty of people have already had this problem before you and there have been plenty of solutions
I would suggest not actually ever destroying it, but rather disabling the object. (This is also faster and more efficient than Destroy)Another method is to use Invoke and CancelInvoke to "cancel" destroying the object (however this can only be used in some cases)
Hope this helps,Benproductions1
I understand the use of disabling object, I was just curious as to whether I could intervene and remove an object from the destruction queue that Unity has.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
18 People are following this question.
using Contains(gameObject) to find and destroy a gameObject from a list
How come when the player runs into the coin it won't destroy?
DontDestroyOnLoad Slowing Loading Down
How to delay lines of code.
Why is my MonoBehaviour never being deleted?