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.

Recognize a tap gesture anywhere

AdurnatAdurnat
edited April 2017 in Questions And Answers

Hello, I'm a bit new to Hololens development. I'm using the holotoolkit on Unity and I would like to be able to recognize a tap gesture anywhere. I followed the hologram courses but there are many things I don't know about C# so it's quite complicated for me, so I'm trying to figure it out using the holotoolkit's API.

Is there a way to recognize a tap gesture anywhere? Something simple like :

OnInputClicked(InputClickedEventData eventData)
{
//Do stuff
}

(I found that in TapToPlace.cs)

But this only works when the script is attached to an object and I have a scene with dozens of objects.

By the way, I do have an InputManager GameObject placed in my hierarchy.

Best Answer

Answers

  • Woah, it worked instantly ! Thank you very much !
    For those wondering, here is the code I wrote :

    using UnityEngine;
    using HoloToolkit.Unity.InputModule;
    
    public class HideObjects : MonoBehaviour, IInputClickHandler
    {
    private void Start()
    {
        InputManager.Instance.PushFallbackInputHandler(gameObject);
    }
    
    public virtual void OnInputClicked(InputClickedEventData eventData)
    {
         //DoStuff
         Debug.Log("Click !");
    }
    }
    
Sign In or Register to comment.