UI Updating Late?

I have a code that changes a buttons color on click (to show it’s activated). The script works fine, but I have to click on something else on the UI to actually get it to work. Is there a way around this? Like when the button is pressed instantly re-render it to the new color? I’ve tried OnGUI() and in the Update(). Neither makes a difference.

Solved Issue by using the Image Component instead of the button Component and messed around with my code. Not really sure how I fixed it but I did!!! This thread can be deleted!

Yes GUI is updated late so you should make your changes in LateUpdate for it to take effect.
However it might be simply be better to override the IPointerClickHandler interface and update it within the click event. Or have a function called by the click event to alter the GO behavior.

Hope that helps

Thank you! I ended up making a class that’s called upon the click event. It seems to work pretty good! Thanks for the advice.

1 Like