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

Object handle more than one method?

I followed this tutorial from hololens academy. My question is, does an object (hologram) able to hold more than one method other than OnSelect()? If that so, does everything has to be fired using SendMessageUpwards()?

Answers

  • Options

    @CooperStrike ,

    You can have more than one method and they can be called anything you like. Not just OnSelect. You can use SendMessage or SendMessageUpwards (these are Unity syntax, not HoloLens).

    Is this what you were looking for?

    James

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

  • Options

    Thanks for the response, @james_ashley
    I did try that. However, another issue arose.
    My testing was simple, just to show a text from the object being gazed at (and trigger it with clicking) but now the ability to place the object to different location is not working (it can be moved but can't be placed again once 'grabbed').

    Also, what is the difference of SendMessage and SendMessage upwards?

  • Options

    @CooperStrike,

    SendMessageUpwards bubbles up to parent objects (while SendMessage doesn't). This can be handy if you have a complex gameobject with multiple clickable parts and just want the method on the top most gameobject to get called.

    For the other, it sounds like the gazegesturemanager and/or gesturemanager is confused about what the second tap means you are trying to drop the object or trying to trigger your text.

    If you are combining the 101E tutorial with the HoloToolkit (where the TapToPlace script is found) it could be even more confusing since they aren't totally compatible. In that case, you might have two GestureRecognizer gameobjects trying to detect the same tap. (Can't tell without seeing the code, though.)

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

  • Options

    @james_ashley
    So the setup is still similar (with small adjustments) from the one in academy.

    • I have the World object (contains the 'GazeGestureManager')
    • Inside that object, there are Stage object (this serves as the parent of all the holograms -- 'TapToPlace' is attached here)
    • Inside stage, there are 3 holograms: The board, and two cubes. Now on these cubes I added a script to show text.

    Now, the GazeGestureManager seems to recognize the show text method well but not the case for 'TapToPlace' one.
    And I only have one GestureRecognizer

  • Options

    @CooperStrike,

    Gotcha. The next step, then, is probably to put in debug breakpoints to see which method is intercepting your air tap. Also, definitely use SendMessageUpwards in a scenario like that (you have one tap handler on an ancestor and another on a child object, I believe).

    James

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

  • Options

    @james_ashley
    I still can't figure it out. I can move the object but I can't put it back, it will stay forever in my grasp until I shut the system.
    Is there by any chance you can make a very simple example showing how 2 methods work?

    Much appreciated!

  • Options

    @CooperStrike,

    Sadly, the 101E code no longer works for me. It's pretty old. Can you paste your two methods and I'll try to see if I can find any problems?

    James

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

  • Options

    @james_ashley Ok I used the code from the academy only with a minor change to the GazeGestureManager (since it has to call two methods).
    So I will tell you which part that I have changed.

    GazeGestureManager
    // Send an OnSelect message to the focused object and its ancestors. if (FocusedObject != null) { FocusedObject.SendMessageUpwards("OnSelect"); }
    Becomes:
    if (FocusedObject != null) { FocusedObject.SendMessageUpwards("OnSelect"); FocusedObject.SendMessageUpwards("DisplayText"); }
    CubeCommands
    For this, I just changed the class name. it is actually the same with SphereCommands (from Academy). The difference is I remove the OnSelect() method here and add DisplayText() method
    void DisplayText() { OnOff = !OnOff; if (OnOff) { ShowText.gameObject.SetActive(true); } else { ShowText.gameObject.SetActive(false); } }

    TapToPlaceParent
    This is the same code with one from academy, as you notice the OnSelect() method is shown here.

    That's it. Really appreciate if you can figure out the issue :smile:

  • Options

    @CooperStrike,

    I got a version of this working, finally. My best guess is that when the OnSelect method, is called, the stage object is picked up and moves around with your gaze, but you no longer have an object as the focus. Then when you try to do the second airtap, since nothing has focus, the second OnSelect can't find its receiver. I discovered this by adding an extra line to the GazeGestureManager:

                    Debug.Log("focused object: " + FocusedObject.name);
                    FocusedObject.SendMessageUpwards("OnSelect");
                    FocusedObject.SendMessageUpwards("DisplayText");
    

    The work around would be to either add some sort of mesh collider to the stage object itself, so it can be the focus of a gaze, or make the colliders for your two object much bigger.

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

  • Options

    @james_ashley Ok, going to try this.
    Will update you with the result.
    Thanks man

Sign In or Register to comment.