|
Hello, I have a question if there is a way to detect in the OnDestroy() function if the object is destroyed because the level is closing/game is closing. I have an object (soldier) that is spawning other objects in some situations (health-bar etc.). In the soldier's OnDestroy() I also remove all objects that the soldier spawned (soldier keeps references). The code looks like this: class Soldier{ } When I close the editor I get the MissingReferenceException because Unity destroyed the m_CreatedObject before Soldier object when the game is closed. What can I do in this situation?
(comments are locked)
|
|
No, there isn't- but that's why the callback exists! Use this to destroy the sub-elements before the game would close, preventing the OnDestroy problems from occuring. Ehhh sorry. I was not aware of such callback. This will solve my problem. Thank you!
Mar 06 '12 at 11:32 PM
mstruzyna
No need to apologise! That's what this site is for, after all.
Mar 07 '12 at 12:34 AM
syclamoth
(comments are locked)
|
