Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

UI and script synchronization

Discussion in 'UGUI & TextMesh Pro' started by HRV-Simulation, Apr 10, 2017.

  1. HRV-Simulation

    HRV-Simulation

    Joined:
    Oct 27, 2016
    Posts:
    6
    Hi everybody,
    I need to synchronize an UI Textbox with a computed value (i.e. scoring system) within a script at Update(). My problem is that when I pause the simulation when the score is reaching a specific value. Sometime, the displayed value in UI doesn't fit the computed value (in script).

    I understand that the UI refresh is not exactly the same as the script update. So, how could I make sure that the UI value match the computed one ? I already tried to check if canvas score (by parsing text) is equal but it doesn't work either.

    Thanks for your help,
    Yoann
     
  2. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,632
    Step forward after pausing the editor by one frame, and you should see the "then updated" gui values.

    As far as at runtime, the delay should not be perceivable really...
     
  3. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    6,106
    Unless your score needs an exact value computed every frame for some reason, you should be able to just set the score after something changes it. For example if you pickup an item that adds 100 points. Add the points and then set the text on the UI.

    I have never experienced any issues with it not showing the correct value.
     
  4. HRV-Simulation

    HRV-Simulation

    Joined:
    Oct 27, 2016
    Posts:
    6
    The score is not for gaming purpose, actually it's an ergonomic assessment. I perform a cotation of a subject's posture tracked with a motion capture system in real time.
    My problem occurs while I playback a motion and when I want to pause the capture replay if the cotation reach a certain level. I'm computing the cotation within an Update() method and it's never stopped even if the repaly is in pause.
    My "Pause" mode is simply the motion played going from speed = 1 to speed = 0.
     
unityunity