Search Issue Tracker
By Design
Votes
0
Found in
2020.1.0a1
2020.3
2021.2
2021.2.7f1
2022.1
2022.2
Issue ID
1399713
Regression
Yes
Asset in Editor Default Resources fails to load on startup when using AssetPostprocessor and InitializeOnLoad on said asset
Reproduction steps:
1. Open the user attached "LoadBug.zip" project
2. Notice the "Unable to find required resource at flag-nl.png" error in the Console
3. Reimport Assets/Editor/MyPostprocessor.cs and reopen the project
4. Notice that the "Unable to find required resource at flag-nl.png" error does not occur
5. Select Assets/Editor Default Resources/flag-nl.png
6. In the Inspector set "Texture Type" to "Normal map" (trigger the Postprocessor)
7. Apply and reopen the project
8. Observe the Console
Expected result: No errors are logged
Actual result: The "Unable to find required resource at flag-nl.png" error is logged again
Reproducible with: 2020.1.0a1, 2020.3.27f1, 2021.2.10f1, 2022.1.0b6, 2022.2.0a3
Not reproducible with: 2019.3.0a12, 2019.4.35f1
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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note (2022.2.X):
While this appears to be a regression in behaviour, it actually relates to a deliberate bug fix.
Previously, postprocessors with a version number of 0 (such as the one in this repro) were ignored when creating the internal hash for postprocessors, which was a bug that was fixed.
In this case, the [InitializeOnLoad] callback is fired before the custom postprocessor is registered, so the asset is unavailable.
Previously the asset was available, but because the postprocessor was not registered, it was probably not functioning as expected.
Because [InitializeOnLoad] is triggered when there is a domain reload, which can happen during an import, it's not guaranteed that all assets will be imported (and therefore loadable) because of dependencies such as these.
To load the texture when it is known to be imported and loadable, one can use OnPostprocessAllAssets() or EditorApplication.delayCall instead.