Back to Writing
NOTESunityscene-loadinginitializationlifecycle

Unity - RuntimeInitializeOnLoadMethod: Running Code Before Scene Load

October 12, 2020Updated Feb 17, 2026

![](

88_rfPAedVWAk8zMeAg.ETtnLTBYgf9VuLPI2m8EEUExk4PwEj8YkooZaCN9VZ8g.PNG.cdw0424/image.png?type=w966)

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]

Applying this attribute above a function causes it to execute just before the scene is loaded and started.

Since the function information must be known before the scene starts, it must be a static method.

Generally, Awake is sufficient, but if you need to handle device configuration or other setup before the game starts, this is the way to go.


Unity - Scripting API: RuntimeInitializeOnLoadMethodAttribute