Search Unity

UI Updating Late?

Discussion in 'UGUI & TextMesh Pro' started by RobertFitzgibbon, Mar 4, 2015.

  1. RobertFitzgibbon

    RobertFitzgibbon

    Joined:
    Mar 2, 2015
    Posts:
    32
    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!
     
    Last edited: Mar 4, 2015
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    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
     
  3. RobertFitzgibbon

    RobertFitzgibbon

    Joined:
    Mar 2, 2015
    Posts:
    32
    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.
     
    SimonDarksideJ likes this.