Skip to content

Update state visualizer and add tests#1123

Open
keveleigh wants to merge 14 commits into
MixedRealityToolkit:feature/XRI3from
keveleigh:update-state-visualizer-and-add-tests
Open

Update state visualizer and add tests#1123
keveleigh wants to merge 14 commits into
MixedRealityToolkit:feature/XRI3from
keveleigh:update-state-visualizer-and-add-tests

Conversation

@keveleigh
Copy link
Copy Markdown
Contributor

@keveleigh keveleigh commented Jun 2, 2026

  • Fixed bug where the interactable could be changed but the visualizer would stay subscribed to the old interactable.
  • Fixed bug where the animator could be changed but the visualizer wouldn't update the AnimationPlayableOutput.
  • Added tests for hot-swapping Interactable and Animator on StatefulVisualizer.
image

@keveleigh keveleigh self-assigned this Jun 2, 2026
@keveleigh keveleigh requested a review from a team as a code owner June 2, 2026 20:54
@keveleigh keveleigh enabled auto-merge (squash) June 2, 2026 21:44
Comment on lines +143 to +153
set
{
if (animator != value)
{
animator = value;
if (playableGraph.IsValid())
{
animationPlayableOutput.SetTarget(animator);
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! I updated the setter to disable the old animator and ensure the new one's state matches the playable graph.

Comment on lines +383 to +398
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;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😅

@keveleigh keveleigh disabled auto-merge June 3, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants