From Unify Community Wiki
Revision as of 14:10, 19 February 2006 by NCarter (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In my own experiments with this class, I discovered that, when testing the game in the editor, s_Instance would tend to retain the instance used in the previous run of the game unless the script was recompiled. To avoid that, I used the Awake event to explicitly set the reference to the new object.

The problem with this trick is that it might mean that the instance reference isn't ready for other objects' Awake events if they get called before ours (they might get the previous game's object again). To avoid that, I've changed it to use OnApplicationQuit to set the current instance reference to null. This ensures that it will always be invalid the next time the game is run in the editor, which will cause a new object to be created. --NCarter 09:10, 19 February 2006 (EST)

Personal tools