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
- Unable to undo or redo color swatch changes when creating or deleting color swatches
- [Linux][Vulkan] Silent crash when tooltip appears while hovering over a label
- Material Properties are not preserved when overriding Shader using Render Objects
- Scene view flickers when both Scene and Game view are active and DX11 API is used with Gamma Color Space
- ZivaRT Player and ML Agents packages Deprecated label color differs from other Deprecated packages
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