c# - Setting a button to it's highlighted color state? -
is there way through scripting set button start @ highlighted color state rather it's normal color state? have 2 buttons select 2 different custom keypads , want 1 of them automatically selected on start, therefore i'd button associated keypad selected (in highlighted state). way this?
you can try changing main color through script.
you can create togglebutton, add image component , toggle component via script :
toggle mytogglebutton = gameobject.find("mybuttonname").getcomponent<toggle>();
then add script button :
mytogglebutton.onvaluechanged.addlistener(mybuttonaction);
and mybuttonaction() method can :
void mybuttonaction(bool state){ if(state) toggle.getcomponent<image>().color = color.green; else toggle.getcomponent<image>().color = color.ref; }
or if don't want add image component toggle, can play mytogglebutton.colors
by way, can choose initial state of toggle button, highlighted color can default 1 if toggle state true default.
Comments
Post a Comment