1

I would have several questions for the community:

As a short version:
  1. Are there any tutorials on how to create 3D UIs in Unity. Primarily for the Hololens 2, for example with the MRTK toolkit?
  2. As an explicit question how can I create a scrollable text (TextMeshPro) with a slate prefab?

For Questions 1:

I have only recently started working with the Hololens 2. I also have not yet gathered much expert knowledge with creating UIs in Unity. I have noticed that the prefabs in MRTK are built differently than the typical Unity UIs (which I have seen in tutorials). As an example, no canvas but only rects are used. On the MRTK UX page the prefabs are shown but not how to create and arrange your own elements.

For Questions 2:

My detailed question now is about the MRTK Slate Prefab. I would like to display text that I add dynamically in a TextMeshPro on a slate (e.g. in the ContentQuad) and scroll it with interactions. Like on the smartphone via up/down swipe scrolling. In the prefab a mesh material as content is used (which is a png). So I can't pass the TextMeshPro or the rect directly. If I use the text material as mesh material and use a box collider the text is not readable and not scrollable. Is there a solution which i don't see? A similar question was asked here, but was not answered (I tried to ask the question different/more accurately though).

Alex
  • 151
  • 10

2 Answers2

2

As a person who has used a lot of UI slates for Hololesn 2 and 1 over the past 2 years, I can try to help you with it.

Q1:

None that I know of. They have provided detailed instructions on how to make a Button with all the elements from scratch here. I am not sure you are right. They also use canvas elements too especially where the texts need to be visible.

Q2:

I can give a direct solution here. I have edited the UGUI slate from MRTK so that there are only Text mesh pro components and scroll view. You can download the prefab and start using it. Here is the link.

I would suggest playing around with the slate and trying to add and remove components and see how it affects the slate. It will then make sense to you.

Hopefully, this helps.

holouser
  • 172
  • 11
  • A huge thanks for the help. I'm still trying to understand the division (hierarchy) of the folders and why 5 TextMeshPro are in the viewport but I'll figure that out. So thank you for a practical example which helps to understand more complex UIs. – Alex Aug 01 '22 at 05:58
  • The scrollview did not work when I added only one TMP, so I had to add few more . However I ended up using only one at the top – holouser Aug 02 '22 at 12:26
  • Unfortunately, it does not work at all for me. When I load your prefab and enter a long text in the first TMP, it just flows over the background. Unfortunately this is only visible through the glasses but not with the help of screenshots/videos (i don't know why?!?). That's why I have displayed another attempt of mine next to it where you can also see this effect in the video. Furthermore, you can scroll an extremely small distance, but as soon as you do not touch the object, it is moved back again. What exactly am I doing wrong? [Example Video](https://youtu.be/TjhFSYvNndk) – Alex Aug 03 '22 at 10:02
  • 1
    I had this problem too. I added the ContentSizeFitter component on the Content gameobject (Child of ViewPort) to overcome this issue. Currently, in the prefab, Vertical Fit field on the ContentSizeFitter is set to Min Size, change this to Preferred Size and it should work(I tested this today) – holouser Aug 10 '22 at 10:02
  • First of all, thank you for helping me. I have moved the elements in all possible directions and started from scratch with an empty slate - without success. As you described I also have put the ContentSizeFitter on the Content gameobject and set the Vertical Fit to Preferred Size . In the editor (see [[ScrollableSlate.png](https://postimg.cc/hQrd2cqM)) it looks right but as soon as I deploy the application to the Hololens the text overflows again. – Alex Aug 10 '22 at 12:28
2

Now it finally works!

For everyone else who also has problems with text that goes beyond the viewport, I'll leave the answer here:

@holouser solution works perfectly. All you need is an empty MRTK slate where you insert a scroll view instead of the ContentQuad. As described in the comments, a ContentSizeFitter is placed on the Content gameobject with Vertical Fit set to Preferred Size. One TextMeshProUI inside the Content is also sufficient.

It is important to set the Depth Buffer to 24bit in the build settings (see also issue) so that the text does not overflow from the slate when deploying to the Hololens2.

Alex
  • 151
  • 10