In our iPhone game, we’ve combined many of our buttons and gui icons onto one texture sheet. This works fine if we’re using a plane to display the image, we can map it onto a place and move its uvs around so that it only shows the certain button we’re looking for. No problem.
The problem is with our guiTextures. It seems it uses the whole texture. Is there a way to clamp out a certain part of the texture or crop in some way so we can use our guiTextures and our texture sheet to save memory?
Ready for this crazy hack? I put 4 button images on one texture sheet and got it to work with guitextures by doing the following:
Put one button in each corner of your texture atlas. Make sure you have a transparent background to the texture atlas and each button has some transparent space around it. Load the texture atlas onto the guitexture and use the border numbers to “clamp” the certain part of the texture that you want, and set the height and width to 500,000, effectively stretching the rest of the texture into obscurity, never to be seen again… muahaha.
I know this post is ancient, but what kind of luck have you had with GetPixels/SetPixels as a dynamic way to write textures during runtime?? I ask because I was trying to find a way to use a texture atlas to use with the GUI for reducing draw calls. It seems like a heavy process and I’m targeting iOS. I came up with a quick mock up with a GUITexture and it works, but I was wondering if the benefits of minimizing draw calls out weighs the negative aspect of having to store huge arrays of colours and iterating through them to write to a texture every time you need to change something ( it’s sure hard to balance the GPU/CPU with mobile development )…
Anyhow, I was wondering what kind of luck you had with it?