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

How can I capture click events on objects generated programatically?

DeanWinchDeanWinch
edited May 2017 in Questions And Answers

Hello! I have a number of models, each with a large amount of child objects. For each child object, I want to be able to select it with a click (airtap). Since there are hundreds of child objects, I want to be able to process them through code rather than the Inspector.

For each child object in the model, I am adding a MeshFilter and a BoxCollider. Is there anything else I need to add for it to work? The attached script implements IInputClickHandler, and breakpoints/debug shows that no events are triggered.

I am using the InputManager prefab, and click events work fine with my UI Buttons. However, I am not able to capture click events for my model objects.

Any ideas would be much appreciated, thank you!

Best Answer

  • Options
    DeanWinchDeanWinch
    Answer ✓

    Aha, problem solved.... I had SpatialMapping left out of the layer mask for GazeManager, but apparently there were two UI layers. One of them contained a canvas covering the screen, and was in the layer mask, so it caught all the events. The other UI layer had a menu which was closer than the canvas, so it worked fine.

    Thanks anyways Pranav!

Answers

  • Options
    edited May 2017

    Hi,

    First of all, is your cursor changing color or shape when you gaze at the object? If it is, then the problem must be with the gesture. Could be anything from Gesture Manager/Input Manager (depending upon the version of HoloToolKit you're using) to the script which tells the object what to do when an airtap is performed.

    If the cursor isn't changing color or shape:
    1) There might be a problem with the gaze manager, since you have already added the Box Collider. Or
    2) If you're using a HoloLens, and if you haven't used occlusion on any of your objects, make sure that the objects are not behind a wall or any other obstruction. This would make the cursor gaze at the wall instead of the object which is behind the wall. We wouldn't know the difference because we can still see the object and the cursor on top of it without realizing that it is actually gazing at the wall. In this case make sure that the objects are nearer to the camera. Ideally around 3 m in front of the camera (this distance was ideal in my surroundings).

    Hope this helps,
    Pranav

  • Options
    DeanWinchDeanWinch
    Answer ✓

    Aha, problem solved.... I had SpatialMapping left out of the layer mask for GazeManager, but apparently there were two UI layers. One of them contained a canvas covering the screen, and was in the layer mask, so it caught all the events. The other UI layer had a menu which was closer than the canvas, so it worked fine.

    Thanks anyways Pranav!

  • Options
    edited May 2017

    Cool. You're welcome :)

    Pranav

Sign In or Register to comment.