Caveats
CK Wiki - Notes
- When this event is received any calls to the object that manipulate it may fail.
- This event may not be sent if an object is in an unattached cell when a save is made, and then the save is loaded (the 3d is never loaded by the savegame process, so it never 'unloads'). Keeping track of the ObjectReference.OnCellAttach() and ObjectReference.OnCellDetach() events is usually more reliable.
- This event is only sent when an object's 3d is unloaded. This may or may not have anything to do with its parent cell and/or the player's location in the world. Don't rely on it happening every time a player leaves the parent cell, even an interior.
Examples
Event OnUnload()
Debug.Trace("This object has been unloaded, animations can't be played on it anymore")
endEventAuto-Generated Example
Scriptname MyCoolScript extends ObjectReference
event OnUnload()
Debug.trace("Event received - OnUnload")
endEvent