- Home /
Stopping the destruction of a gameobject
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
Hello there,
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.
Thanks!