- Home /
Access sprite texture data from atlas
I have a spritesheet that is configured as multiple and this works great for 2D stuff. There is one image that I am using as a sprite but I also want to access that same image data as a texture2D so I can assign it to a quad on a 3D object. If I use sprite.texture I get the entire atlas and I just want to copy the single sprites image data from the atlas.
So how can I programably get just the sprite image data and stuff it into a textre2D?
Answer by Eric5h5 · Nov 25, 2014 at 12:42 AM
You can use Sprite.rect to get the pixel coordinates of the texture. You can then either copy those pixels to make a new texture, or ideally just change the UVs of the quad so it only displays the desired part of the texture.
Thanks Eric, I also found this script which helped - http://answers.unity3d.com/questions/651984/convert-sprite-image-to-texture.html
How do you copy the pixels if that requires read/write to be enabled, when enabling that prevents the sprite packer from including the sprite in the atlas?
Your answer
Follow this Question
Related Questions
iOS Sprites in PVRTC? 1 Answer
Resize a sprite by giving it more transparent pixels 0 Answers
My sprite from sprite.create looks pixelated. 1 Answer
Convert a Texture2D to Sprite 2 Answers