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.
Options

Counter number of airtaps

mdoukmdouk
edited June 2017 in Questions And Answers

Hello everyone,

At some point in my app in need to check the number of airtaps the user has perfomed. Then based on this number I want to make some evaluations.
Is there a way to achieve that with the latest HoloToolkit in Unity? I have found in the Initialize method of the InputClickedEventData the TapCount variable but I think its purpose is different.

Thank you!
Michael

Tagged:

Answers

  • Options
    ReeleyReeley ✭✭✭

    Im not quite sure what you want^^

    If you just want to get the total airtap count the user has performed, then just create a script, implement the IInputClickHandler interface, add the script as a global listener to airtaps, like this:

    private void Start()
    {
        InputManager.Instance.AddGlobalListener(gameObject);
    }
    

    Or do you want something like if a user airtaps X times in a timespan Y -> do something?

  • Options
    mdoukmdouk
    edited June 2017

    Hi again. I have multiple panels that are activated deactivated with voice commands ("Next", "Back"). In a particular Panel I want the user to click an exact number of times before something happens. So imagine something like the following:
    `if (clicksCounter <10)
    {
    //do something
    }

        else if (clicksCounter == 10)
        {
            if (isEqual)
            // do something
        }
       else
            // do something
    

    `

    all i want is to increment the int clicksCounter each time the user performs an airtap. I know that this interpretation is a bit different from my original post.

    PS. why some lines of code are not marked as special text even though they are inside the two ''?

  • Options
    ReeleyReeley ✭✭✭
    edited June 2017

    Ok so i suppose you know how to implement the IInputClickHandler.

    Then you just have to do something like this:

    int clickCounter = 0;
    
    public void OnInputClicked(InputClickedEventData eventData)
    {
        clickCounter++;
        if (clickCounter < 10)
        {
            //do something
        } else if(clickCounter == 10)
        {
            //do something
        } else // clickCounter > 10
        {
            //do something
        }
    }
    

    and add this script to your panel

    PS. are you writing the '' ? if so try the formatting button above the textbox i have no problems then

  • Options

    that's exactly what I am doing but the counter is not incrementing...

  • Options
    ReeleyReeley ✭✭✭

    then i guess the problem is that the function is not called

    add a Debug.Log in the OnInputClicked so you know for sure its not called.

    also try the thing with the global listener just to test if the function gets called.

    PS. you implemented the interface right? like this:

    public class MyClass : MonoBehaviour, IInputClickHandler{
    
    }
    
Sign In or Register to comment.