- Home /
Sprite editor and texture
I have one png with many buttons. I want to use the sprite editor to slice it to single buttons. it works fine, but I can't use the sliced buttons as textures for GUI.drawTexture. I can only use them as sprite.
How can I use the sliced buttons as textures in guiTexture?
Comment
Answer by Tomer-Barkan · Jan 02, 2014 at 03:28 PM
You cam use GUI.DrawTextureWithTexCoords() which allows you to select specific coordinates within the texture to draw.
So say each button is 100x100 pixels, then to draw the second button (top row, second column), you'd use:
Rect buttonPosition = new Rect(100, 0, 100, 100);
Rect screenPositionToDraw = new Rect(400,300,100,100);
GUI.DrawTextureWithTexCoords(screenPositionToDraw , texture, buttonPosition);
Thanks but my problem is that the buttons don't have an exact distance between each other. so that's why i want to uee the sprite editor on automoatic slicing