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

Resolved Sprites invisible when loaded via Addressables in Build

Discussion in 'Addressables' started by Malecden, Jul 10, 2022.

  1. Malecden

    Malecden

    Joined:
    Mar 1, 2014
    Posts:
    5
    I'm working on loading sprites to a player object using Addressables and I'm running into a weird issue. When I start the game in editor everything works perfectly. But when I build and run the player becomes invisible after loading the sprite.

    The handles are being managed through a Race handle class since I'm loading other data as well, but I tested the issue with this simplified code in the Start method:

    Code (CSharp):
    1. new AssetReference("Base Assets[Lycas]").LoadAssetAsync<Sprite>().Completed += sprite =>
    2. {
    3.        _spriteRenderer.sprite = sprite.Result;
    4. };
    And still get the same result.

    What's interesting is that there are no errors, and it seems to be able to find the sprite. I validated this by logging the name of the Player's current sprite on every frame and it does change to "Lycas" after the call finishes.

    Appreciate any help. This is my first time using Addressable, so forgive me if I'm missing something simple.
     
  2. Malecden

    Malecden

    Joined:
    Mar 1, 2014
    Posts:
    5
    So, the solution was to add my Sprite Sheet to a Sprite Atlas and the problem disappeared.
     
  3. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    Hey, sorry you ran into that. First off, thanks for trying out Addressables! I'm glad you were able to find a workaround. It sounds like there might be some weirdness with the build and sprites. I can try and see if it reproduces for me, but don't hesitate to file a bug. In the event it's a build issue, another team will actually have to look at it.

    Thanks!