Skip to content

Remove CanvasSliderVisuals Update polling, refactor UpdateValue helper, and add tests - #1144

Open
keveleigh wants to merge 1 commit into
MixedRealityToolkit:mainfrom
keveleigh:fix/521-canvas-slider-visuals
Open

keveleigh wants to merge 1 commit into
MixedRealityToolkit:mainfrom
keveleigh:fix/521-canvas-slider-visuals

Conversation

@keveleigh

Copy link
Copy Markdown
Contributor

Fixes #521

Changes

  • CanvasSliderVisuals:
    • Removed per-frame Update() polling.
    • Added Editor-only OnValidate() to reactively apply layout and handle updates when inspector properties (SliderDirection, etc.) change.
    • Added EnsureSliderEndpoints() helper to lazily resolve sliderStart/sliderEnd RectTransforms.
  • Slider:
    • Added UpdateValue(float newValue, bool forceUpdate = false) helper to centralize value setting, clamping, step division snapping, and event firing.
    • Re-snapped and updated value when UseSliderStepDivisions or SliderStepDivisions properties are changed.
    • Updated Slider.OnValidate() to call UpdateValue(value, forceUpdate: true) so modifying the slider value in the Inspector during PlayMode immediately propagates OnValueUpdated.
  • Tests:
    • Added EditMode tests in CanvasSliderVisualsTests.cs verifying endpoint caching, layout orientation changes, inspector OnValidate reactivity, and slider value updates.
    • Added PlayMode tests in CanvasSliderVisualsRuntimeTests.cs verifying runtime handle updates, direction changes, and step division snapping.

Verification

  • EditMode tests: CanvasSliderVisualsTests (5/5 passed)
  • PlayMode tests: CanvasSliderVisualsRuntimeTests (3/3 passed)

@keveleigh keveleigh self-assigned this Sep 26, 2026
@keveleigh
keveleigh requested a review from a team as a code owner September 26, 2026 03:57

This branch has not been deployed

No deployments
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.

[IMPROVEMENT] Useless [ExecuteAlways] and Update() calls in CanvasSliderVisuals, editor slider value not sync in playmode

1 participant