Search Issue Tracker
By Design
Votes
0
Found in
2020.3.40f1
2021.3.10f1
2022.1.17f1
2022.2.0b8
2023.1.0a12
Issue ID
UUM-16595
Regression
No
"InitializeOnLoad" method runs before Asset Database is ready when reimporting with the "Reimport All" option
How to reproduce:
1. Open the attached user project
2. Select the Assets folder, right-click on the folder and press “Reimport All“
Expected result: Message “AssetDatabase.FindAssets: 1“ logged in the Console
Actual result: Message “AssetDatabase.FindAssets: 0“ logged in the Console
Reproduced with: 2020.3.40f1, 2021.3.10f1, 2022.1.17f1, 2022.2.0b8, 2023.1.0a12
Reproduced on: macOS (12.5)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- var VisionOSEDRHeadromm has a comma instead of a dot when building with Metal Rendering App Mode and local OS localization is set to German
- IAP Catalog remove product “x” and add product “+” buttons are not consistent with other remove and add buttons in the Editor
- Performance issues in Play Mode when quickly hovering the mouse cursor over Hierarchy GameObjects
- Frame Debugger displays incorrect output when FidelityFX Super Resolution or Spatial-Temporal Upscaler is used with Temporal Anti-aliasing or Subpixel Morphological Anti-aliasing
- The layout system is failing to correctly calculate or apply the height of the Japanese fallback font when the primary English font's metrics are used
Resolution Note:
This is expected behaviour. From the manual entry for 'InitializeOnLoadAttribute' :
"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."
https://docs.unity3d.com/ScriptReference/InitializeOnLoadAttribute.html