Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Code reload

Understand how and when the Editor reloads parts of your project code, how you can hook into the code lifecycle to perform setup and cleanup at key stages, and how to fix code reload leaks.
Read time 1 minuteLast updated 4 days ago

As you develop and iterate, the Unity Editor automatically reloads your project code as necessary to incorporate changes you make.
It's important to understand how code reload works to avoid issues such as code reload leaks, which can cause memory leaks and other problems in your project.
You can also use Unity's lifecycle APIs to hook into key stages of the code loading and reloading lifecycle, to perform setup and cleanup work or handle Edit mode and Play mode transitions.

Topic

Description

Accessing the code lifecycleUse Unity's lifecycle APIs to hook into key stages of the code lifecycle to perform setup and cleanup work or handle Edit mode and Play mode transitions.
Code reload and assembly load context leaksUnderstand code reload, and diagnose and fix
AssemblyLoadContext
leaks.
Code and scene reload on entering Play modeUnderstand what Unity reloads on entering Play mode and how you can configure this behavior for faster development iteration times.

Additional resources