Drawing Single Sprite from Multiple Sprite sheet onto Label

Hey all,

Just trying to find a way of using a single sprite from a sprite sheet with multiple sprites as the texture for a custom editor window label/button.

So to make it a bit clearer:
-Get a individual sprite from a multiple sprite sheet
-Get it’s texture
-Assign it to EditorGUI Label/Button
-???
-Profit!

Currently using the selected sprite’s texture works, but displays the entire sheet instead of just the one sprite.

Any ideas?

You can’t easily specify texture coordinates with EditorGUI.LabelField, GUI.Label, or GUI.Button. You could pass them a custom GUIStyle with clipping=true and imagePosition set to the correct sprite in the texture, but this seems kind of klunky. Can you use GUI.DrawTextureWithTexCoords instead?

Ah, so am I right in thinking sprites are mainly just coordinates with a reference to their parent texture?

I’ll have a go with your idea later, thanks

The Sprite class provides a little more than that, but that’s the heart of it.