Search Issue Tracker
Fixed
Votes
7
Found in
2018.4
2018.4.22f1
2019.4
2020.3
2021.1
2021.2
Issue ID
1253963
Regression
No
Assets are referenced by ManagedStaticReferenced when Scene is unloaded using SceneManager.UnloadSceneAsync
How to reproduce:
1. Open the attached 'UiMaskBug.zip' project
2. Open 'Empty Scene' Scene
3. Enter Play Mode
4. Press 'Load' button in the Game View
5. Press the 'Unload' button in the Game View
6. Open Window > Analysis > Profiler
7. Select Memory module
8. Switch from Simple to Detailed view
9. Select Take Sample Playmode to capture detailed memory usage
10. Expand Assets and Texture 2D dropdowns
Expected result: 'bg' texture is not referenced by ManagedStaticReference and loaded in memory
Actual result: 'bg' is referenced by ManagedStaticReference and loaded in memory
Reproducible with: 2018.4.36f1, 2019.4.29f1, 2020.3.14f1, 2021.1.15f1, 2021.2.0b4
Not reproducible with: 2022.1.0a3
Notes:
- Video of reproduction attached in Edit
- Using UnloadSceneOptions.UnloadAllEmbeddedSceneObjects does not solve the issue
Comments (1)
-
Eldirfar
Jul 14, 2020 10:14
Current fix for this is adding this script to every GameObject with UiMask
public class UiMaskReferenceFix : MonoBehaviour
{
private void OnDestroy()
{
var image = GetComponent<Image>();
if (image != null)
{
image.sprite = null;
}
}
}
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
- Redoing creation of Sub Scenes and Cube GameObjects in Hierarchy throws “Assertion failed on expression: 'targetScene != nullptr’” error in Console window
- Selecting “New Sub Scene” after assigning “New Scene” in Sub Scene Script Component throws “Destroying GameObjects immediately is not permitted” in the Console window
- Shader Graph "Zoom Step Size" can be set to 0 even though the zoom still works
- Enabling/Disabling the Deprecated Nodes doesn't apply to the opened Shader Graph unless any Variable is added to the Blackboard
- Group Selection title text size is smaller in renaming than the actual font size
Resolution Note:
Not reproducible since 2021.1.10f1, seems to be fixed by unknown PR, which has also been backported and is present in both 2019.4 and 2020.3