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?

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);