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

Sprite Atlas in Asset Bundle not working for UI Image.

Discussion in 'UGUI & TextMesh Pro' started by leondelagarza, Apr 15, 2021.

  1. leondelagarza

    leondelagarza

    Joined:
    Aug 10, 2018
    Posts:
    3
    Hello

    I have a prefab that contains an UI Image. This image references a sprite in a sprite atlas. Both the prefab and the sprite atlas are in the same asset bundle. However, when I instantiate the prefab from the asset bundle, the image is not loaded.

    What am I doing wrong?

    Here is my prefab:


    Here is my sprite atlas configuration:


    Here is my asset bundle contents:


    Here is how I am instantiating the prefab:



    Here is the complete test project, if any of you want to take a look:
    https://github.com/leon945/ABTests

    Thanks in advance!
     
  2. mylastggeast

    mylastggeast

    Joined:
    Jun 14, 2021
    Posts:
    47
    @leondelagarza Have you find a solution? I am facing the same issue. It works on the mobile build though, it seems to be an issue only in the Editor. The funny thing is that re-assigning the texture manually works at run time.
     
  3. leondelagarza

    leondelagarza

    Joined:
    Aug 10, 2018
    Posts:
    3
    Hi @mylastggeast

    I did notice it works when you reassign at runtime, weird indeed. I don't recall exactly, but I think this was happening on builds for me as well.

    Unfortunately I never found a solution and opted for simply not using a sprite atlas. I might end up re-investigating at a later date.