Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Bug Wrong index order in spritesheet on Addressables build.

Discussion in 'Addressables' started by JJNoguera, Feb 10, 2021.

  1. JJNoguera

    JJNoguera

    Joined:
    May 12, 2019
    Posts:
    5
    The problem is simple: I'm loading an spritesheet with Addressables, and then accessing the individual sprites through the returned IList by index:

    Code (CSharp):
    1. IList<Sprite> sprites = await AssetLoader.LoadAssetReference<IList<Sprite>>(spritesRefs[currentSprites]);
    2. SpriteRenderer.sprite = sprites[currentSprite];
    Nothing too complex, it works well. That's it, until you build the Addressables and use the "Use Existing Build" in Play Mode Script or build the game and execute it outside the Editor, then when it should show the sprite in index 8 it show index 4 instead for some reason beyond my comprehension.

    Anyone knows why and / or have a possible solution? Thanks in advance!
     
    Last edited: Feb 18, 2021
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,796
    I'll forward to the team for some input. Which version of Addressables are you using?
     
  3. JJNoguera

    JJNoguera

    Joined:
    May 12, 2019
    Posts:
    5
    Thanks! I tried with both 1.15.1 and 1.16.16 in Unity 2020.2.3f with the same result.

    If someone has the same problem and until it's fixed, I recommend using Unity's SpriteAtlas instead of spritesheets with IList in the meantime if that is an option.
     
  4. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    294
    Hi,
    I tried producing this behaviour, but did not work. If possible, could you file a bug report displaying the problem?
    It's good that SpriteAtlases work for you. It may be personal preference, but SpriteAtlas can give you more control if you need to modify your Sprite setup later down the line. e,g mix more SpriteSheets together. So it is good that works for you.
     
  5. ctv_tristanou

    ctv_tristanou

    Joined:
    May 7, 2021
    Posts:
    1
    I'm encountering the same issue, and was able to reproduce it. I submitted a bug report (1393960). It'd be really nice if this was addressed, as I have so many sprites that it would be very painful to convert them all to sprite atlases. :)