oddgames / UIToolkit

Single draw call UI solution for Unity with multi resolution support and more.
518 stars 153 forks source link

Changing Highlighted image is awkward #148

Open Crushy opened 11 years ago

Crushy commented 11 years ago

I'm trying to make a multi-purpose button that will display an image of the currently selected level. This means I need to change it's "regular" sprite and the highlight sprite. My code currently looks like this:

LevelPreview.setSpriteImage("IconLevel_" + lvlIndex+ ".png");
LevelPreview.highlightedUVframe = this.levelSelectToolkit.uvRectForFilename("IconLevel_" + lvlIndex+ ".png");

Maybe I'm nitpicking but this doesn't look too healthy. We could argue that UIButtons weren't created for this sort of behaviour but that makes the setSpriteImage method seem a bit useless by itself.

I could submit a patch for UIButtons but I'm sure the problem would manifest itself for other components that use more than one sprite.

Crushy commented 11 years ago

I also want to add that even that code has issues: When the mouse is released outside the button the highlight button set on creation is left behind instead of the new one.