Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sprite Atlas white sprites problem

Discussion in 'Addressables' started by androshchuk-vladyslav, Jul 17, 2019.

  1. androshchuk-vladyslav

    androshchuk-vladyslav

    Joined:
    Dec 13, 2015
    Posts:
    127
    Hi! Let's describe a problem:
    • I've imported 3 sprites for 3 button states
    • I've added new SpriteAtlas and put folder with 3 sprites in "Objects for Packing"
    • Made a scene with UI Button
    • Binded 3 sprites to different Button states (sprite swap)
    • Builded Player Content
    • Run game in Packed Play Mode (with hosted service)
    • Loaded that scene via Addressables
    • After load I can see button with image
    • After press, sprite converted to white one
    • After loading another scene and go back to previous one, all Images was white
    Bundle Browser shows images and atlases in bundle.
     

    Attached Files:

  2. androshchuk-vladyslav

    androshchuk-vladyslav

    Joined:
    Dec 13, 2015
    Posts:
    127
    Moreover, I had code like this:
    Code (CSharp):
    1.  IconsHandle = Addressables.LoadAssetsAsync<Sprite>(new List<object>(Icons), null, Addressables.MergeMode.Union);
    2.         IList<Sprite> icons = await IconsHandle.Task;
    3.  
    4. IconPrefab.InstantiateAsync(iconPosition, Quaternion.identity).Completed += icon =>
    5.                 {
    6.                     icon.Result.transform.SetParent(ReelsContainer, false);
    7.                     icon.Result.GetComponent<SpriteRenderer>().sprite = iconToInstantiate;
    8.                 };
    If Icons are just Addressables, all work nice. But if I place one of that icons on scene and rebuild bundles, that icon will be broken:
    upload_2019-7-17_13-38-7.png

    Looks like problem with dependency packing.
     
  3. androshchuk-vladyslav

    androshchuk-vladyslav

    Joined:
    Dec 13, 2015
    Posts:
    127
    That problem occurs only after switching scenes with:
    Code (CSharp):
    1. Addressables.LoadSceneAsync(Name + "/Scenes/MainScene");
    Also I have:
    upload_2019-7-17_16-59-38.png

    P.S. After building for macOS, problem from post 1 disappeared, left only problem with shaders after scene switch. Problem in Editor still the same.
     
  4. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Can you file a bug against Unity with a repro project? We've seen some similar issues elsewhere, but having your repro will really help us get to the bottom of this.
     
  5. androshchuk-vladyslav

    androshchuk-vladyslav

    Joined:
    Dec 13, 2015
    Posts:
    127
    I sent a report. There is lack of Zenject of last version to be workable and maybe some project settings. Let me know if you need something more. Case 1170466.
     
    firstuser and unity_bill like this.
  6. firstuser

    firstuser

    Joined:
    May 5, 2016
    Posts:
    147
    @unity_bill for what it's worth I think this issue may have re-surfaced. I'd file a bug report but it's been so hard to reproduce. Basically exact same problem, all my sprites get turned into white/scrambled portion of sprite atlas showing when unloading an unrelated addressables scene (async/additive).

    Unity 2020.1.11
    Addressables 1.16.7

    @AndersonDev wondering if you have been running into this since your report? Surprised you were able to reproduce it, it happens roughly 1/100 for me.
     
  7. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    303
    Does anyone know if there's a way to detect that this happened? For example, would the sprite in the SpriteRenderer/Image component be null in a build?

    I would test it myself, but I can't reproduce the issue. It just happened randomly sometimes in 2020.3.14. I just upgraded to 2021, so maybe that will fix it.

    Even if we can't fix the bug, it would help if I could just log an error as soon as the game boots up with those invalid sprites, but I remember trying and failing to diagnose this before. I'm pretty sure the sprite references weren't null when the Addressables finished loading, but when I looked at the frame debugger, the shader's _MainTex was blank instead of pointing to the Sprite Atlas.
     
  8. Cow-Worker

    Cow-Worker

    Joined:
    Jun 25, 2020
    Posts:
    1
    It appeared in our project after we implemented sprite atlases. Some of them are on single big sprite (which is atlas), some of them are inside dynamic sprite atlas (.spriteatlas files). Also some of them are in addressables, some are not if it may be related. But still after first opening project I get scrambled parts of atlases or somewhere white sprites. The most interesting thing is that if you look at Inspector window, sprites are set and exists. Even though I can't see them in preview box while play mode. I looked into frame debugger and while rendering these sprites the _MainTex is set to none.
    After restarting unity editor sprites become okay.But still after building the game for android or iOS some sprites are seems to be missing. May anybody explain what's going on and how exactly it works?
    P.S. We use Unity 2020.3.29f1
     
    _eternal likes this.
  9. vectorized-runner

    vectorized-runner

    Joined:
    Jan 22, 2018
    Posts:
    396
    This bug still persists. One the sprite loaded from the spriteatlas becomes the spriteatlas texture itself. We're not using addressables (but using assetbundles). I don't know the exact case but I'm now considering that it's an engine bug.