Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

In which order of event functions is the animation update during editor preview fired?

Discussion in 'Animation' started by Xarbrough, Jun 24, 2019.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,085
    The documentation for order of execution of event functions explains nicely in which order certain functions are called. At runtime, I know that Update is called, then animations are update and then LateUpdate is called. For a special system in our current project I need to make sure that my own script updates in LateUpdate just before rendering, because I need to wait for an animation apply its changes to specific transforms first. This works nicely at runtime.

    However, in edit mode, when previewing the animation with the Animation Window or via Timeline, my update logic does not work. I'm using the ExecuteAlways attribute on my MonoBehaviour class and LateUpdate is called, but apparently the order of events is different at edit times and my script lags behind one frame after the animation update.

    I will be experimenting some more to find out which of the event functions will be correctly timed, but I also wanted to ask if there is any official information about this and if it could be added to the documentation?

    Additionally, I would also prefer having the order of events be fired the same in edit mode (animation preview update between Update and LateUpdate) for consistency and less ugly code to handle both cases.
     
    akent99 likes this.
  2. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    115
    Thank you for sharing "ExecuteAlways" - I was pulling my hair out but that was the trick that got my animation script working in preview mode.
     
unityunity