InitializeOnLoadAttribute

class in UnityEditor

切换到手册

描述

允许在 Unity 加载时初始化编辑器类,无需用户操作。

Note that static constructors with this attribute are called when Unity starts and when Run is pressed. In this second case the Unity runtime is intialised and this is treated as a Load.
See the manual page about running editor code on launch for further details.