- Home /
Question by
enerology · Aug 23, 2020 at 09:20 PM ·
sprite packer
How to get generated texture of sprite atlas in editor from script?
I would like to assign my atlas texture to a material texture for my Graphics.DrawMeshInstancedIndirect to use in the editor, but I can't find a texture that is not generated at runtime?
Comment
Bump, the only way I found to get the texture is at runtime using
sprites = new Sprite[unityAtlas.spriteCount];
unityAtlas.GetSprites(sprites);
Texture2D spriteAtlasTexture = sprites[0].texture;
//This only works at runtime and if I call it in editor, I get the imported texture and not atlas texture.
Best Answer
Answer by enerology · Aug 23, 2020 at 11:33 PM
This works for getting the texture of an atlas from editor script or !runtime by using any sprite packed in it.
SpriteUtility.GetSpriteTexture(sprites[0], true);
Your answer
Follow this Question
Related Questions
Sprite Atlas split into 2 by Unity, why? 0 Answers
SpriteAtlas Compression 0 Answers
how to use tk2d Sprite with NGUI Camera? 1 Answer
Sprites are stretched after packing with sprite packer 1 Answer
Sprite Packer Mode question. 0 Answers