MixedRealityToolkit-Unity: Button.OnButtonClicked is triggered twice on clicks

Overview

OnButtonClicked is triggered twice on input clicks. Once from the InputClickedEvent and once from InputDown. This happens spread over some frames and thus causes unintended side effects with dialogs and button actions that spawn gameObjects infront of the user. For example the first InpudClicked event will open a Dialog and the second will imediately dismiss it.

buttonclicktrace

Expected Behavior

OnInputClicked is only fired once

Actual Behavior

OnInputClicked is fired twice

Steps to reproduce

  • Create empty scene
  • Add default MRTK stuff
  • Add Button
  • Trace OnButtonClicked

Unity Editor Version

2017.3.1f1

Mixed Reality Toolkit Release Version

dev branch @ d46126f8bfb0d27355d40e37afe3ad4dee920601

Edit: Added commit hash

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

I have a rework in progress, so I’ll be sure to double check #2040 as well.

DoButtonPressed is the problem here. It contains both, OnButtonPressed and OnButtonClicked, while it’s been called from both, OnInputDown and OnInputClicked.

I created a test scene for you in here: https://github.com/thiemok/MixedRealityToolkit-Unity/tree/feature/button_test You can find it in Assets/buttonTest.unity I also went ahead and and added eventData.Use() to Button.cs, to show that the problems is not created by rehandeled events. https://github.com/thiemok/MixedRealityToolkit-Unity/commit/ff2c4e395be3ebffc27b72cc8537a99e61a8433b

Disclaimer: i could not base the test of the current dev branch, because of some exception, so i used d46126f8bfb0d27355d40e37afe3ad4dee920601