When using Addressables(Use Existing Build) and SpriteAtlas together, the textures may not be displayed correctly.
The procedure is as follows.
-
Assign an image to the sprite of the image in the prefab. Register it as PrefabA in Addressables. Also, make this sprite into a spriteAtlas and put it in the Addressables as well.
Set Bundle Mode to Pack Separately. -
Set the Play Mode to Use Existing Build and run the Default Build Script.
-
Start the scene, load PrefabA there, Instantiate it, and GameObject.DontDestroyOnLoad(newObj), Just in case, the loaded handle should be Addressables.ResourceManager.Acquire.
-
Now, run LoadScene to switch to other scene.
-
When SetActive(true) is applied to a pooled PrefabA, the sprite atlas image is not displayed correctly(white box).
I checked the memory in Profiler, I see that the atlas texture is still in memory at the time of 3.
However, when I switch scenes in 4, the atlas textures seem to have been released.
Is this a specification? or am I using it wrong?
If we are using a pool of prefabs across scenes, as shown above,
Do I need to Addressable.LoadAssetAsync the SpriteAtlasAsset of the sprite assigned to the prelab in advance?
Please help, Unity Technologies.
Unity: 2020.3.18f1
Addressables: 1.18.16
I will also send you a sample that confirms this problem.
1.Open AATestWithSpriteAtlas in Unity2020.3.18f1
2.Set the Play Mode in Addressables to Use Existing Build and run the Default Build Script.
3.Select the startup scene and EditorPlay it.
4. click the ‘1.load prefab’ button
5. click the ‘2.change Scene’ button
6. click the ‘show loaded prefab’ button
7. Make sure four white images appear at the top.
The correct behavior is to display a sprite called “option_page_bg”.
7547254–932698–AATestWithSpriteAtlas.zip (63.1 KB)