Search Issue Tracker
By Design
Votes
0
Found in
2019.4
2020.3
2021.2
2021.2.3f1
2022.2
Issue ID
1384425
Regression
No
Asset Database operations not working correctly when invoked from [InitializeOnLoadMethod] after rebuilding the project database
Reproduction steps:
1. Open the attached user's project
2. Notice that 'Data (Data)' is printed in the console
3. Close the project
4. Delete the Library folder from the project directory
5. Open the project again
Expected result: 'Data (Data)' is printed in the console
Actual result: 'Null' is printed in the console
Reproducible with: 2019.4.36f1, 2020.3.30f1, 2021.2.13f1, 2022.2.0a5
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
- Editor freezes briefly when "multi-selecting" TextMeshPro GameObjects In the Hierarchy window in Prefab Mode, if 5 or more Inspector windows are open
- OnEndDrag event not triggered when losing Editor focus during simultaneous Left and Right mouse drag
- Texture displays visual artifacts and has a broken aspect ratio when it is imported in RGB 48-bit format
- Diagnostic Warning Resets When Navigating Away and Returning to Diagnostics Settings
- Checkbox Collides with Text in Shader Graph Preferences Settings
Resolution Note:
This is expected behaviour. Asset Operation in InitializeOnLoad should be avoid because this is called before asset importing is completed. In 2021.2 a variant of the OnPostprocessAllAssets callback got introduced that includes a didDomainReload parameter. This callback is safe for asset loading.
https://docs.unity3d.com/2021.2/Documentation/ScriptReference/AssetPostprocessor.OnPostprocessAllAssets.html
It is also mentioned in the doc that asset operation in InitalizeOnLoad should be avoided:
https://docs.unity3d.com/2021.2/Documentation/ScriptReference/InitializeOnLoadAttribute.html