Before updating to Windows 10 you may need to return your Pro license. More information here

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.

more ▼

asked Jun 29, 2013 at 01:02 AM

avatar image

68 5 9 13

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

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 (http://lmgtfy.com?q=unity+cancel+destroy) 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,

more ▼

answered Jun 29, 2013 at 03:03 AM

avatar image

13.4k 32 34 64

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.


Jun 29, 2013 at 03:58 AM spanagiotis

btw, the lmgtfy link is not appreciated, because this is first thing that comes up when you google gameobject stop destroy.

May 07, 2014 at 09:50 PM Pyromuffin
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Jun 29, 2013 at 01:02 AM

Seen: 1262 times

Last Updated: May 07, 2014 at 09:50 PM