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.

Creating a moveable UI

I'm looking to create a moveable UI, so the user can place various elements. Currently I have a UI consisting of some buttons on a canvas. Is there a way to make the canvas movable using the TapToPlace script? Or do I have to create a UI from 3D objects?

Best Answer

  • HoloSheepHoloSheep mod
    Accepted Answer

    @nax when you say "doesn't work with TapToPlace" can you provide a little more detail?

    Does the TapToPlace script initiate the move logic, but doesn't let you place it?
    If so, that might be because the origin of the panel is set to the center by default.

    With the canvas I think it is pretty easy to move the origin to where you want it.
    I think if you change the Pivot values on the Canvas from x = .5 y = .5 to x = 1 y = 1 that might work if it is the "place" part of the TapToPlace that isn't working since the logic in that routine moves the object around with your view based on the objects origin. That origin spot then becomes un-tappable if the origin is not inside the collider.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

Answers

  • @Nax, yes you need to set the canvas Render Mode to World space.

    Few more pointers to using Unity UI in this other post.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • NaxNax
    edited June 2016

    @HoloSheep That didn't seem to work. The cursor appears behind the canvas, and the canvas isn't selectable (the buttons are selectable however).

    Edit: I've attached a picture of my settings.

  • Does your canvas have a collider?

  • @timg I have tried it with a box collider, mesh collider and a 2D box collider. So far none have worked.

  • @nax add a 3D Box collider to the Bowtie Canvas and use Edit Collider to size it as a 3D wrapper around your canvas.

    One option if you want to avoid overlapping your buttons etc. is to just put the box collider over the top section of the canvas like a header (similar to the header the shell puts on 2D windows) and if you do, from a good UX point of view you might want to adorn that section of the canvas with color or some other hint to the user that it is an active area for moving the canvas.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • @HoloSheep I had a similar solution. I set a Quad as a parent to the Bowtie Canvas, and used the Quad to move the canvas around.
    For some reason when I add a box collider to the canvas, it doesn't work with TapToPlace, however, the cursor still detects it.

  • HoloSheepHoloSheep mod
    Accepted Answer

    @nax when you say "doesn't work with TapToPlace" can you provide a little more detail?

    Does the TapToPlace script initiate the move logic, but doesn't let you place it?
    If so, that might be because the origin of the panel is set to the center by default.

    With the canvas I think it is pretty easy to move the origin to where you want it.
    I think if you change the Pivot values on the Canvas from x = .5 y = .5 to x = 1 y = 1 that might work if it is the "place" part of the TapToPlace that isn't working since the logic in that routine moves the object around with your view based on the objects origin. That origin spot then becomes un-tappable if the origin is not inside the collider.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • @HoloSheep Originally it would sometimes initiate the move logic and other times it would select but not allow placing, however, moving the pivot seems to have fixed it!
    I set the pivot to x=.5 and y=1.

    Thanks for your help!

Sign In or Register to comment.