x


Method like Awake(), but for destroying an object?

Awake() is called when a script is being loaded. Is there a similar method for when a script is being unloaded or disabled? Or some other way that your script can know it's being unloaded? Should I just use a destructor?

more ▼

asked Jul 05 '12 at 02:20 PM

Moohasha gravatar image

Moohasha
117 3 8 12

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

2 answers: sort newest
more ▼

answered Jul 05 '12 at 02:31 PM

Drakestar gravatar image

Drakestar
916 6 7 14

Duh! Awake() and Start() don't begin with "On", so I just glanced over all of the methods that begin with "On" in the documentation. Guess I should have been a little more careful. =P

Jul 05 '12 at 06:22 PM Moohasha
(comments are locked)
10|3000 characters needed characters left

You can also use OnDisable and OnEnable for information about an object being enabled and disabled in addition to OnDestroy().

more ▼

answered Jul 05 '12 at 02:39 PM

whydoidoit gravatar image

whydoidoit
33.1k 12 23 101

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

x215
x20
x5

asked: Jul 05 '12 at 02:20 PM

Seen: 307 times

Last Updated: Jul 05 '12 at 06:22 PM