x


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

spanagiotis gravatar image

spanagiotis
18 4 8 9

(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,
Benproductions1

more ▼

answered Jun 29, 2013 at 03:03 AM

Benproductions1 gravatar image

Benproductions1
12.8k 27 32 53

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!

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 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

By RSS:

Answers

Answers and Comments

Topics:

x3467
x1194

asked: Jun 29, 2013 at 01:02 AM

Seen: 753 times

Last Updated: May 07 at 09:50 PM