Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. 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:
    43
    @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.