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.

Unity ViewportToWorldPoint - Emulator Ignores

Jarrod1937Jarrod1937 ✭✭✭
edited April 2016 in Questions And Answers

Hello, it seems that the unity emulator ignores just about everything related to the camera. A lot of things work fine in Unity (in editor and standalone), but when I try it in the emulator the items just appear wherever.
For example, doing a Camera.main.ViewportToWorldPoint(new Vector3(0.5F, 0.5F, 3)) yields the world coordinates for a point at 50% height, 50% width of the viewport at 3 meters away. However, while this works in regular Unity, it is ignored by the emulator when trying to position an item there every frame update.
Basically I'm wanting to place a canvas (in world coordinates) at a specific spot in front of the camera, but I need to do so programmatically as I have other plans. Is there a way to do this with the Hololens and Unity?

Answers

  • First, please do review the guidance on designing for mixed reality. What you are wanting to do is referred to in that document as 'display-locked' content. This is simple to accomplish, but if overdone could cause your application to be uncomfortable to use for an extended time.

    That being said, you can accomplish what you want by:
    Vector3 position = Camera.main.transform.position + Camera.main.transform.forward *3;
    This will be the same point you are describing. ViewportToWorldPoint probably should be returning the same thing, but I've never tried that API.
    (also I don't have access to a PC ATM, so I couldn't double check my casing in the code above).

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • Jarrod1937Jarrod1937 ✭✭✭
    edited April 2016

    Great, I will give that a try, thank you. And I agree, I don't plan on having it really fixed per se, I want to having 3D interface that they can look around with head movement. However, a lot of the existing methods for this are truly fixed to the viewport, which doesn't work with gaze tracking and would be a bit of an eye sore. I just need a method to get something to map to the viewport to at least get me started.

  • Awesome, sounds like you are putting the correct amount of thought into this. :)

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

Sign In or Register to comment.