- Home /
How to get access to the texture generated by built-in Sprite Packer?
I have a tile map which takes sprites from my assets and combines them into one mesh. Now I need to assign material with the atlas texture generated for sprites (sprite atlas).
The problem is that when I take material from one sprite that uses the atlas I need, and assign that material to the map, I get a material with no texture. And attempts to get texture from the sprite return null.
How do I get the sprite atlas texture?
So far Unity devs told me that it's impossible to get an access to the atlas texture at runtime.
Answer by tmsduman · Jun 25, 2015 at 12:59 PM
Try the Sprite Utility GetSpriteTexture with true as second parameter and set the texture to your material. Other wise Paker.GetAtlasDataForSprite can be helpful in your case.
One of the Unity devs told me that it is impossible to get the entire atlas texture, unfortunately. But thank you for the answer.
But this is editor-only, right? That doesn't help at runtime.
Answer by tim12332000 · Jun 05, 2019 at 07:04 AM
Sprite[] sAry = new Sprite[_spriteAtlas.spriteCount];
_spriteAtlas.GetSprites(sAry);
Texture2D t = sAry[0].texture;
This is working for me.
Your answer
Follow this Question
Related Questions
How to get correct UVs for sprite in a Unity Sprite Packer-packed atlas? 0 Answers
SkinnedMeshRenderer offset UVs to match texture atlas? 1 Answer
How To Apply A Texture Atlas For UI Image Objects? 0 Answers
One atlas per scene or one (larger) atlas across multiple scenes? 0 Answers
How can I combine 4 textures into one bigger texture at runtime? 1 Answer