Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Unexpected behavior while using Sprite Atlas' with Asset Bundles

Discussion in '2D' started by Mikeysee, Jan 12, 2018.

  1. Mikeysee

    Mikeysee

    Joined:
    Oct 14, 2013
    Posts:
    155
    Hi Guys,

    Im trying to use Sprite Atlas' and asset bundles and getting some unexpected behavior. Checkout the video below:



    The steps to recreate

    1. Create new project (projectA)
    2. Add a Cat Sprite to the project.
    3. Create a SpriteAtlas and add the Cat Sprite.
    4. Create a scene that contains a GameObject with a SpriteRenderer.
    5. Create a script that given a SpriteAtlas and sprite name it pulls the sprite out of the Atlas and sets it on the SpriteRenderer.
    6. Press play, note the cat shows on the screen.
    7. Build the bundles.
    8. Create another project (projectB)
    9. Copy over the bundles from projectA.
    10. Create a script in projectB that loads the scene bundle.
    11. Press play, note the scene loads but the cat doesnt show.

    What I expect to happen is that in step 11. the cat sprite should show.

    I tried unpacking the generated bundle from projectA using this tool: https://github.com/DerPopo/UABE and the texture is indeed within the bundle:



    A related post to this one is: https://forum.unity.com/threads/spriteatlas-assetbundle-unable-to-use-sprites.494462/

    That one however is dealing with the situation where the atlas is contained in a different bundle to a prefab that depends on it. In my case, the atlas is contained within the same bundle as the scene so it should just work.

    It looks like @Kuan from Unity was very helpful with that post so hopefully he can he assist with this one too.

    I have uploaded the two projects here:
    https://www.dropbox.com/s/9zihri4293r2jd3/AtlasBundlesTestProjectA.zip?dl=0
    https://www.dropbox.com/s/w72d7tnmazrijgp/AtlasBundlesTestProjectB.zip?dl=0

    Cheers.
     
    Last edited: Jan 12, 2018
    Slot-Galaxy and ajon542 like this.
  2. Kuan

    Kuan

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    87
    Hey @Mikeysee

    Looks like this is a bug. I built a player from ProjectB and it works fine with the player. Just in editor we are seeing this missing texture reference. We will convert this into a bug and hopefully find a resolution for this quickly.

    I will post here when we have more update.

    Thank you for reporting this!
     
  3. Mikeysee

    Mikeysee

    Joined:
    Oct 14, 2013
    Posts:
    155
    Hi @Kuan thanks for confirming that for me.

    Is there any work around that I can use for now that you can think of?
     
  4. Kuan

    Kuan

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    87
    I think you will have to work on both scene in the same project for now.
     
unityunity