LifecycleAttributeBase
Base class for lifecycle callback attributes.
Read time 3 minutesLast updated 6 days ago
Definition
- Type: Class
- Namespace: Unity.Scripting.LifecycleManagement
- Assembly: Unity.Scripting
- Inherits from: RequiredMemberAttribute
public abstract class LifecycleAttributeBase : RequiredMemberAttribute
Remarks
This is the abstract base class for all lifecycle callback attributes. Do not inherit from this class directly; use the specific lifecycle attributes instead:
- OnCodeLoadedAttribute / OnCodeUnloadingAttribute - Code loading lifecycle.
- OnCodeInitializingAttribute / OnCodeDeinitializingAttribute - Object serialization lifecycle.
Lifecycle Timing:
Code reload order (Editor only):
- OnCodeDeinitializingAttribute - Objects serialized.
- OnCodeUnloadingAttribute - Code about to unload.
- (Code unloads and reloads)
- OnCodeLoadedAttribute - Code loaded.
- OnCodeInitializingAttribute - Objects deserialized.
Initial code load (Editor and Player):
- OnCodeLoadedAttribute - Code loaded.
- OnCodeInitializingAttribute - Called before initial scene loads.
Shutdown (Editor and Player):
- OnCodeUnloadingAttribute - Code about to unload.
Additional Resources: OnCodeLoadedAttribute, OnCodeInitializingAttribute.