ex-makina / marklight

MarkLight is a presentation framework for Unity that allows you to create scene elements in a language similar to HTML.
MIT License
75 stars 35 forks source link

How to style a button to have alpha or scale value when user press #7

Closed takaaptech closed 7 years ago

takaaptech commented 7 years ago

Hi, I just found it is awesome GUI lib for unity! I try to make custom theme for button with single image for both state: normal and pressed, and i want when user pressed, image change alpha value (or scale to 1.1):

<Button Id="home" BackgroundImage="Sprites/640_18.png" Width="102" Height="102"/>

How can i get it? Thank so much!

P/S It is very easy to define Pressed-BackgroundImage with new alpha value or scale value but i think we should support alpha or scale directly on BackgroundImage for better size and performance!

patrik-u commented 7 years ago

Hi

As you suggested you can set Pressed-Alpha="..." and Pressed-Scale="..." on the button. If you want to change fields on the image component that the Button (UIView) doesn't provide mapped fields to, then you can access them directly through the ImageComponent field. E.g:

<Button Pressed-ImageComponent.color="#000000" />
takaaptech commented 7 years ago

Awesome! I just test and it works as expected! Thank you so much! So i assume that our document and our api are not up to date..