Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

UI Button On Click() event firing twice

Hello!

I have the Holo Lens Input Module (script) with Holo Lens Input (script) in the EventSystem. Standalone Input Module (script) is unchecked but not removed.

With the script, I am able to airtap on UI Buttons. However, my event handler (attached to On Click through the Inspector) gets fired twice. This happens in both the emulator and the device. I noticed in the emulator, if I click my mouse quickly (to emulate airtap), then the event fires twice. If I click and hold for a while, before letting go, the event is only fired once. Finally, if I click away from the button, drag over the button while still holding, then release, the event only fires once.

I also went to InputManager and deleted everything there (Axes Size = 0).

Any ideas?
Thanks in advance!

Best Answer

  • DeanWinchDeanWinch
    edited March 2017 Answer ✓

    So I found the problem is from the Holo Lens Input Module, and I have a solution. However, I don't know the exact reason, maybe someone else can comment on what exactly each property does.

    I tried the following values for "Time To Press On Tap" and "Repeat Delay":
    (Time To Press On Tap, Repeat Delay, Works?)
    0.3, 0.5 nope
    0.5, 0.3 nope
    0.5, 0.8 nope
    0.8, 1.0 nope
    0.8, 2.0 nope
    1.0, 0.3 nope
    1.5, 0.5 YUP
    2.0, 1.0 YUP
    2.0, 1.3 YUP

    • "Input Actions Per Second" left untouched at 10 (default).

    It seems the "Time To Press On Tap" has to be somewhere above 1.0. I didn't try the values between 1.0 and 1.5, but 1.5 is working consistently for me (both emulator/device). No double firing of the events at all, but I can still click very quickly to start many coroutines.

Answers

  • chiddaanchiddaan
    edited March 2017

    Hi @DeanWinch,

    I don't really have answer for your question but rather I was hoping you could help me with something that I am trying to do today.

    Using canvas and buttons, I created a UI. I wrote code for click events, which works well in the Game mode of Unity.(It basically is navigation from one canvas to another). I am wondering how to do same in HoloLens?

    How are you getting the click events for the buttons? or How are you clicking(or air-tapping) the buttons on your UI from HoloLens?

    It'd be great if you could help. Thanks.

  • Hi @chiddaan, I just added the Holo Lens Input Module to EventSystem. The script comes with HoloToolkit.

  • Oh thanks, :) I am able to click the buttons but I cannot see the cursor yet. lol.. Thanks a lot.

  • Can you add logs to see where the events are coming from?

    Also, are there two colliders or two interactibles on the button?

    Taqtile

  • DeanWinchDeanWinch
    edited March 2017 Answer ✓

    So I found the problem is from the Holo Lens Input Module, and I have a solution. However, I don't know the exact reason, maybe someone else can comment on what exactly each property does.

    I tried the following values for "Time To Press On Tap" and "Repeat Delay":
    (Time To Press On Tap, Repeat Delay, Works?)
    0.3, 0.5 nope
    0.5, 0.3 nope
    0.5, 0.8 nope
    0.8, 1.0 nope
    0.8, 2.0 nope
    1.0, 0.3 nope
    1.5, 0.5 YUP
    2.0, 1.0 YUP
    2.0, 1.3 YUP

    • "Input Actions Per Second" left untouched at 10 (default).

    It seems the "Time To Press On Tap" has to be somewhere above 1.0. I didn't try the values between 1.0 and 1.5, but 1.5 is working consistently for me (both emulator/device). No double firing of the events at all, but I can still click very quickly to start many coroutines.

  • edited February 2018

    Hi,I tried your method,but failed,It still clicks twice,I need your help.

  • Im using Holographic button from toolkit (or those custom buttons created by the AppBar for BoundingBox)...and they all trigger event twice each time they are clicked/airtapped (in editor and deployed to hololens)

    anyone else experience that, or better yet..have solution ?:)

  • dbarrettdbarrett ✭✭✭

    @braden make sure you don't have more than one EventSystem in your scene. There is one already in your scene under the InputManager. So if you have another somewhere in your scene this could be what it causing the problem.

    AR Developer

  • @braden Check out the InputManager's prefab and its EventSystem. There should be a StandardInputModule. Check the inputActionsPerSecond and the RepeatDelay. Ours is currently set to 10 and 0.5

    Taqtile

  • thanks guys..good suggestions. Can only see one EventSystem in hierachy (including at runtime), and StandardInputModule has 10 / 0.5 already.

    I created a new 2017.2.1.p4 project, copied in MRTK "dev branch working".
    Did MR config project/scene settings.
    Added Bounding Box Rig to a sphere primitive.
    Created basic script to handle InteractionReceiver, which just prints name of object.
    Defined a custom button 'Test' on the AppBar prefab.
    Added the InteractionReceiver script to AppBar prefab and assigned it to the custom button's event target.
    Assigned AppBar and BoundingBoxBasic prefabs to the BoundingBoxRig

    Run

    Click on Test button
    Prints output twice.

  • What are the stack traces on the logs of each click output? I'd find where they are stemming from. If it is the same place then add logs there to discern if it is triggering twice at the source or if it is triggering twice on the listener. That should help narrow down the issue.

    Taqtile

  • btnTest : InputDown
    UnityEngine.Debug:Log(Object)
    myInteractionReceiver:InputDown(GameObject, InputEventData) (at Assets/myInteractionReceiver.cs:12)
    MixedRealityToolkit.UX.Receivers.InteractionReceiver:OnInputDown(InputEventData) (at Assets/MixedRealityToolkit/UX/Scripts/Receivers/InteractionReceiver.cs:240)
    MixedRealityToolkit.InputModule.InputManager:m__6(IInputHandler, BaseEventData) (at Assets/MixedRealityToolkit/InputModule/Scripts/InputManager.cs:451)
    UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction1) MixedRealityToolkit.InputModule.InputManager:HandleEvent(BaseEventData, EventFunction1) (at Assets/MixedRealityToolkit/InputModule/Scripts/InputManager.cs:256)
    MixedRealityToolkit.InputModule.InputManager:RaiseSourceDown(IInputSource, UInt32, InteractionSourcePressInfo, Object[]) (at Assets/MixedRealityToolkit/InputModule/Scripts/InputManager.cs:460)
    MixedRealityToolkit.InputModule.InputSources.CustomInputSource:SendControllerStateEvents(Single) (at Assets/MixedRealityToolkit/InputModule/Scripts/InputSources/CustomInputSource.cs:408)
    MixedRealityToolkit.InputModule.InputSources.CustomInputSource:UpdateControllerState(DebugInteractionSourceState) (at Assets/MixedRealityToolkit/InputModule/Scripts/InputSources/CustomInputSource.cs:395)
    MixedRealityToolkit.InputModule.InputSources.CustomInputSource:UpdateControllerData() (at Assets/MixedRealityToolkit/InputModule/Scripts/InputSources/CustomInputSource.cs:338)
    MixedRealityToolkit.InputModule.InputSources.CustomInputSource:Update() (at Assets/MixedRealityToolkit/InputModule/Scripts/InputSources/CustomInputSource.cs:275)

    So the bolded line triggers just once on airtap....just trying to figure out how to filter out events in the subsequent functions, as they're fired by other events too.

  • DaTruAndiDaTruAndi ✭✭
    edited April 2018

    Similar issue with HoloGraphicButton.

    I wonder if this rather in the Button implementation.
    I see the following fire in a sample scene based on the samples found.

    OnButtonClicked handler gets called through:
    OnHoldStarted calls DoButtonPressed() which calls OnButtonClicked
    OnInputDown - same thing
    OnInputClicked calls DoButtonPressed(true)
    TriggerPressed same thing

    ...
    a "regular" click triggers both OnInputDown and OnInputClicked when I just tested who each eventually call my OnButtonClicked event handler (through DoButtonPressed)

    It seems to be addressed/talked about here:
    https://github.com/Microsoft/MixedRealityToolkit-Unity/issues/1879

    ... I think I implemented what was suggested there, but it did not fix it.

Sign In or Register to comment.