Hi Guys,
Im trying to use Sprite Atlas’ and asset bundles and getting some unexpected behavior. Checkout the video below:
The steps to recreate
- Create new project (projectA)
- Add a Cat Sprite to the project.
- Create a SpriteAtlas and add the Cat Sprite.
- Create a scene that contains a GameObject with a SpriteRenderer.
- Create a script that given a SpriteAtlas and sprite name it pulls the sprite out of the Atlas and sets it on the SpriteRenderer.
- Press play, note the cat shows on the screen.
- Build the bundles.
- Create another project (projectB)
- Copy over the bundles from projectA.
- Create a script in projectB that loads the scene bundle.
- 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: GitHub - SeriousCache/UABE: Asset Bundle Extractor and the texture is indeed within the bundle:
A related post to this one is: SpriteAtlas + AssetBundle unable to use sprites
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.