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
- "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
- Missing spaces in "Welcome to VR Mutiplayer Template Project" Welcome Dialog window
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.