Search Issue Tracker
By Design
Votes
13
Found in
5.6.1p3
Issue ID
926907
Regression
No
Resources.UnloadUnusedAssets unloads textures that are only referenced by MaterialPropertyBlocks
When using a MaterialPropertyBlock to set a texture for a material, if the texture not referenced somewhere else, it gets unloaded when calling Resources.UnloadUnusedAssets.
Steps to reproduce:
1. Open the scene MaterialPropertyBlock.unity
2. Enter Play Mode
3. Note that the texture on the cube is loaded at runtime
4. Press Space to call Resources.UnloadUnusedAssets
Result: Note that the cube turns to black.
Note: Removing the [PerRendererData] attribute from the _MainTex property of the ShaderTest shader shows how after unloading unused assets the texture used by the material becomes null.
Reproduced with: 2017.2.0b2, 2017.1.0f2, 5.6.2p2, 5.5.4p1.
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:
ShaderPropertySheet is volatile data/unserialized data and therefore can't be tracked easily. The workaround is to either keep a dummy material reference in the scene or reuploading the texture to GPU upon calling UnloadUnusedAssets.