Search Unity

Addressable Sprite Texture not included in AssetBundle

Discussion in 'Addressables' started by SviperSniper, Aug 30, 2019.

  1. SviperSniper

    SviperSniper

    Joined:
    Mar 1, 2017
    Posts:
    37
    Hey guys,
    we are using Addressable 1.1.10 and have a couple of groups with just a single sprite (not on an atlas) inside.
    After building the bundles and inspecting them in the AssetBundleBrowser editor, it only shows the sprite but not the texture.
    We have other groups with Sprites as well as other assets and they work as intended due to prefab references.

    As soon as we include an asset in the bundle that references the sprite, we can load the sprite with its address.
    So it seems like textures of sprites are not included as long as there is no other reference inside the bundle.

    For now we just added a simple ScriptableObject that references the Sprite and put it in the bundle too.
     
  2. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    Unity 2019.1.8f1 + AAS 1.1.10

    AAS setup - single sprite in local group.
    upload_2019-8-31_11-1-35.png

    ABB
    upload_2019-8-31_11-3-28.png
    Notices that it has one source file (png) and two entries in preload tables one for sprite, one for the raw texture?

    My loading code is trivial and works.

    Code (CSharp):
    1. public class Launch : MonoBehaviour
    2. {
    3.     public List<AssetReference> refs;
    4.     public GameObject go;
    5.  
    6.     void Start()
    7.     {
    8.         // Clear cache in case it's a remote bundle.
    9.         Caching.ClearCache();
    10.         Debug.Log("Caching has been cleared");
    11.         // Load asset.
    12.         Addressables.LoadAssetAsync<Sprite>(refs[0]).Completed += Launch_Completed;
    13.     }
    14.  
    15.     private void Launch_Completed(AsyncOperationHandle<Sprite> obj)
    16.     {
    17.         // Should test success/failure, but I'm lazy here.
    18.         var renderer = go.GetComponent<SpriteRenderer>();
    19.         renderer.sprite = obj.Result;
    20.     }
    21.  
    22. }
    23.  
    If your test result shows any differences, please post more details.
     
    unity_bill likes this.
  3. SviperSniper

    SviperSniper

    Joined:
    Mar 1, 2017
    Posts:
    37
    Thanks for your response.
    I had no time to answer yet.

    We actually have some bundles that only contain one sprite and they work as intended. But just one bundle doesnt work. I will further investigate whether I can found the issue.
     
  4. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    67
    We have the same issue in our project. Using Unity 2019.2.4f1 + addressables 1.1.10

    I've tried to reproduce in the addressable Unity sprite land sample but haven't managed to have a repro.


    More notes:
    * like SviperSniper mentioned it works if I add to the bundle a prefab that uses the sprite (simple UI.image using the sprite)
    * it works in fast mode and virtual mode
     

    Attached Files:

    Last edited: Nov 29, 2019
  5. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    67
    I have managed to reproduce the bug in a small project, bug id 1202583
    There are 2 asset bundles each including a sprite. Viewing them with asset bundle browser, one has the sprite with the texture, the other one only has the sprite. Both asset bundles have the same settings and both sprite texture have the same settings also.

    On Unity 2019.3.0f1 with addressables 1.4.0
     
  6. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    67
    I've found the root cause which is that the sprites that aren't generated properly in the asset bundles have a "spritePackingTag" value set to a non null value. This can be seen by opening the .png.meta file in a text editor. Setting this to null with fix the issue.