Version: 2023.1
언어: 한국어

InitializeOnLoadAttribute

class in UnityEditor

매뉴얼로 전환

설명

Allows you to initialize an Editor class when Unity loads, and when your scripts are recompiled.

Static constructors with this attribute are called when scripts in the project are recompiled (also known as a Domain Reload). This happens when Unity first loads your project, but also when Unity detects modifications to scripts (depending on your Auto Refresh preferences), and when you enter Play Mode (depending on your Play Mode configuration).

Asset operations such as asset loading should be avoided in InitializeOnLoad methods. InitializeOnLoad methods are called before asset importing is completed and therefore the asset loading can fail resulting in a null object. To do initialization after a domain reload which requires asset operations use the AssetPostprocessor.OnPostProcessAllAssets callback. This callback supports all asset operations and has a parameter signaling if there was a domain reload.

See Also: running editor code on launch.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961