Update state visualizer and add tests#1123
Conversation
…uld stay subscribed to the old interactable
…'t update the AnimationPlayableOutput
| set | ||
| { | ||
| if (animator != value) | ||
| { | ||
| animator = value; | ||
| if (playableGraph.IsValid()) | ||
| { | ||
| animationPlayableOutput.SetTarget(animator); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Since StateVisualizer is essentially taking ownership, should we be checking the previous enabled/play state (if there is an active animator) and clean up before changing, at the very least set the old one to disabled?
There was a problem hiding this comment.
Thanks for catching this! I updated the setter to disable the old animator and ensure the new one's state matches the playable graph.
| if (EvaluateEffects() && interactable != null && !interactable.isSelected && !interactable.isHovered) | ||
| { | ||
| // Start asleep if nothing is happening. This prevents the Animator from | ||
| // briefly waking up and applying bind poses with 0 weights, which overwrites | ||
| // values set by other components (like theme binders). | ||
| animator.enabled = false; | ||
| playableGraph.Stop(); | ||
| enabled = false; | ||
| } | ||
| else | ||
| { | ||
| animator.enabled = true; | ||
| playableGraph.Play(); | ||
| enabled = true; | ||
| sleepTimer = keepAliveTime; | ||
| } |
There was a problem hiding this comment.
Be careful on this and make sure it's fully tested, this section has caused me much grief. There are cases where the wieghts have been changed but haven't been pushed through to the Animator before it is put to sleep thus we get quirks. I recommend considering calling playableGraph.Evaluate() again just before the sleep is enabled.
There was a problem hiding this comment.
Ah hmm...I wrote a few more tests, but I'll keep thinking on this one to make sure I've caught everything. "Good" to know it's been a troublesome spot, at least 😅
AnimationPlayableOutput.InteractableandAnimatoronStatefulVisualizer.