Search Issue Tracker
Won't Fix
Votes
0
Found in
2018.2.3f1
Issue ID
1088912
Regression
No
Serialized asset is null when loaded from bundle after using Resources.UnloadAsset
To reproduce:
1. Open attached project "UnloadBugTest.zip"
2. Open "SampleScene.unity" scene
3. Build MacOS Standalone
4. Open built project
5. Press Load button
6. Press Unload button
7. Press Load button
8. Open Player.log and observe that the "Null texture in holder? : True"
Expected result: second time pressing Load should be Null texture in holder? : False
Actual result: Null texture in holder? : True , even though, the texture is loaded and added
Reproduced on:
2017.4.13f1 2018.1.9f2 2018.2.12f1 2018.3.0b5 2019.1.0a4
Notes:
Doesn't reproduce on Editor
Getting NullReferenceException errors in the Xcode when built for iOS device and trying to press Load button.
Also reproduced on Win 10 machine.
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
- “FocusController has unprocessed focus events.” warnings are thrown after adding iOS, tvOS or visionOS Build Profiles
- Holes and different colors appear on default Tree Materials after applying them to the Tree GameObject and undoing changes
- Error indicating that the Text Asset Importer hasn't been disposed properly is logged when switching Importer Type in a Focused Inspector
- Documentation installation shows "Install failed: Validation Failed" when installing Android Build Support module
- Error indicating that the Package Manifest Importer hasn't been disposed properly is logged when switching Importer Type in a Focused Inspector
Resolution Note:
The reason this is happening is that the Resources API and the Asset Bundle API are two different systems and weren't meant to work together. What's happening is that they're unloading just the single asset that's connected to the asset loaded from the asset bundle. Thanks to preload tree optimizations that we can't change, when accessing the gameobject that's loaded from the asset bundle it only looks at the main asset (the gameobject) to see if it's loaded. They'll have to use Resources.UnloadAllUnusedAssets or whatever that API is because it will unload that main asset from the bundle. When they then reload the asset it'll use the preload tree to load all the dependencies.