How to create a texture atlas?

Hi,

I've created my own texture atlas in photoshop i.e arranging and fitting as many textures I can to optimise the space. From the atlases, I'd like to get an image and assign it to a GUI button or a plane. Is it possible to do that?

example - something like this.

I read in the manual about texture2D.PackTextures but I'm not sure how to use it? How do I call an image from a specific set of coordinates?

Hope someone can help.

Thanks in advance, -Hakimo

Texture2D.PackTextures takes individual images, packs them in (not always that efficiently) and returns you an array of UV rects you can use for setting the coordinates on a mesh.

You could make your own UV coordinates from the image you have above by figuring them out (which would be a pain).UV coordinates are from 0 to 1 inclusive starting with 0,0 being the lower left and 1,1 being the upper right. Take the pixel coordinates of all your images and figure out their 0…1 values.

// 0,1 ------------ 1,1
//     |          |
//     |   PIC    |
//     |          |
// 0,0 ------------ 1,0

You could use Texture Packer, its output, and the TexturePackerParser from this thread to generate and use the data Texture Packer generates. Texture Packer 3 has an ability to make your own exporter so you could make something more unity friendly.