microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

How to setup uGUI for MRTK? #3429

Closed Alexees closed 5 years ago

Alexees commented 5 years ago

Overview

There is a closed post with the same question, but it's from 2017, completely outdated. I was not able to create a uGUI UI that works with the Hololens. The cursor is not hitting the UI, instead just completely ignoring it. In the editor, it does work when holographic remoting it. I tested it adding a TextInput field to the Canvas of the InteractablesGallery scene.

Expected Behavior

It just works

Actual Behavior

The cursor goes straight through the UI

Steps to reproduce

Unity Editor Version

2019.1.0b2

Mixed Reality Toolkit Release Version

mrtk_release, mrtk_development

Alexees commented 5 years ago

@StephenHodgson you've answered the question 2 years ago, haven't you? What's the situation now?

chrisfromwork commented 5 years ago

Hello,

Have you tried adding a HoloLens input module to the scene? For input fields, you may also need to write your own keyboard management logic using unity's TouchScreenKeyboard class.

Alexees commented 5 years ago

Hello,

Have you tried adding a HoloLens input module to the scene? For input fields, you may also need to write your own keyboard management logic using unity's TouchScreenKeyboard class.

Hi, thanks for the response. You mean, the current default scene setup does not support Hololens out of the box as it usually did?

chrisfromwork commented 5 years ago

@davidkline-ms @keveleigh @Yoyozilla @SimonDarksideJ does the default MRTK configure behavior add a HoloLens input module? Does the HoloLens input module conflict with any other MRTK components?

It seems like this component may only be relevant for HoloLens compared to all other AR/VR experiences, which might explain why its not a default component added with the configure step.

SimonDarksideJ commented 5 years ago

The HoloLens input module is a remnant of the HoloToolkit and doesn't apply to the newer MRTK vNext, which implements the same features natively.

Alexees commented 5 years ago

@SimonDarksideJ so why isn't it working then? Or do I need to use it when still on one of the other branches besides vNext?

Alexees commented 5 years ago

@SimonDarksideJ I took a little time to found out what was going on. Unfortunately, uGUI elements created from context menus have all their components Raycast-targets enabled. Since the Text component on a button covers the whole button, along with my guess that the toolkit is using a single raycast, not raycastall, the button for instance is completely blocked. Also the hovering is interrupted on any of the description panels in the example scenes (blocked by the text and image components).

Suggestion: like canvas checks for the ui camera, a lot of the UI elements could be defaulted to not receiving raycasts, except for UI.selectable of course

chenaptx commented 5 years ago

hi it also struggles me a whole day since all the solutions i found by google do not work when it come to the step of setting the event camera to the main camera. finally, i found I need to set the uiraycastcamera of the focus manager first. After that it seems that the click works in the editor but the camera begun to flicker and tremble. have you meet this problem?

Alexees commented 5 years ago

@chenaptx I did not, you should file this as a different problem.

this case is closed as using UI elements works just fine now, except for the need to manually configure raycast target states.

Spoon2311 commented 4 years ago

Hi Using the uGUI-elements works fine for selecting buttons, I struggle with the scrolling using a viewport. I've tried the approaches used in the examples.

Does anyone know how to enable scrolling using uGUI elements with the MRTK v2.2.0?

Thanks