MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Unity UI Button calls OnClick on both down and up events

Open D0miq opened this issue 4 years ago • 2 comments

Describe the bug

On HoloLens 2 when a button in a canvas gains focus, it starts to call its OnClick actions on both down and up events.

To reproduce

I created two test projects. The first contains MRTK Example scenes and the second one just a canvas with a button. Both are attached in zip files.

MRTKTestCanvas.zip MRTKTestCanvasCustom.zip

Steps to create the first test project:

  1. Create a new project in Unity 2020.3.17f1.
  2. Open Microsoft Mixed Reality Feature Tool and install to the project - All Mixed Reality Toolkit 2.7.2 packages, - Mixed Reality OpenXR Plugin 1.0.2.
  3. Open the project in Unity.
  4. Install new input system.
  5. In MRTK Project Configurator select Unity OpenXR plugin.
  6. Setup OpenXR for HoloLens and UWP in XR Plug-in Management.

image image

  1. Switch build platform to UWP.
  2. MRTK Project Configurator opens again with detected OpenXR.
  3. Apply Settings.
  4. Next.
  5. Apply all project settings and UWP Capabilities.
  6. Unity restarts.
  7. Open Unity Package Manager.
  8. In Mixed Reality Toolkit Examples import Demos – HandTracking and Experimental – ExamplesHub.
  9. Open MRTKExamplesHub scene located in Samples/Mixed Reality Toolkit Examples/2.7.2/Experimental – ExamplesHub/Scenes.
  10. Import TMP.
  11. Save MRTKExamplesHub scene.
  12. Open Build Settings and change it for HoloLens 2.
  13. Put MRTKExamplesHub scene on the zero index in the list of build scenes.

image

  1. Build for HoloLens 2 device.

Steps to reproduce the behavior (the first project):

  1. Start the app on HoloLens 2.
  2. Select Hand Interaction examples.
  3. Go to UGUI panels and try to click on a button that should change color of the little square.

image

  1. Starting with the second click, the color will change on every down and up events.

Steps to reproduce the behavior (the second project):

  1. Start the app on HoloLens 2.
  2. Click on the button and the panel changes its background color.
  3. Click again and the color changes on every down and up pointer events.

https://user-images.githubusercontent.com/22446707/133073073-880391a9-868d-49e3-a534-8b6983cf8f24.mp4

Expected behavior

I would expect the OnClick actions to be called only on the up event.

Your setup (please complete the following information)

  • Unity 2020.3.17f1
  • MRTK 2.7.2
  • OpenXR Plugin 1.2.8
  • Mixed Reality OpenXR Plugin 1.0.2

Target platform (please complete the following information)

  • HoloLens 2

Additional context

I tried to install MRTK Examples Hub from Microsoft Store and version 2.6.0.0 works correctly. Interactions with a canvas on HoloLens 1 work correctly as well.

D0miq avatar Sep 13 '21 11:09 D0miq

I'm experiencing a similar problem. I think it also might be related to the previously selected UI button.

Example, I have button A and button B. Scenario 1:

  • Select button A: A's onClick gets triggered once
  • Select button B: A's onClick gets triggered once and B's onClick gets triggered once

Scenario 2:

  • Select button A: A's onClick gets triggered once
  • Select button A: A's onClick gets triggered twice

I also confirmed that this only happens on the HL2 device.

deibu avatar Dec 10 '21 20:12 deibu

I also have the same problem that @deibu describes on the HoloLens 2. This issue only seemed to happen after updating from XR SDK to OpenXR.

The issue also seems to happen with checkboxes as well.

Edit: The workaround in #10304 appears to have fixed my issue.

abeug avatar Oct 06 '22 19:10 abeug

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visithttps://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!

IssueSyncBot avatar Jan 13 '24 00:01 IssueSyncBot