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
- Shader warnings are thrown after building High Definition 3D template
- "EndLayoutGroup: BeginLayoutGroup must be called first" error is thrown when changing Shader Precision Model from the Build Profiles window
- White artifacts/outlines are visible in the Garden Scene when viewing at meshes from a distance
- Shader warnings "Sprite-Unlit-Default" are thrown after building 2D Platrformer Microgame Template
- [Android] HLSL shader becomes corrupted when running on an Android device
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