AndreasSt
AndreasSt

Reputation: 183

Can not get the following UI (see Image) correctly in Unity Editor in World Space (LayoutGroup, LayoutElement, ContentSizeFitter, ...)

i know this might be a lot to ask, but unfortunately i can not get the following UI working in Unity. I experimented a lot with Content Size Fitter, Vertical and Horizontal Layout Groups and Layout Elements, but after a certain depth of the objects it just doesn't want to work the way i want. Always some element scale too much or dont scale at all. I also looked into UIKit, but because the UI is for a VR environment with lots of interaction i wanted to do it "per hand".

I want to create a canvas that scales with its content. Here are some descriptions in case the image is not clear enough. This is also my approach so far.

Canvas: max. width 300, max. height 250, should be in world space

Background Image: should be behind everything else and scale with its content

VerticalLayoutGroup: contains the three elements header, content and button and should help order its elements, the elements should be centered from the top

Header: max height 25, flexible width (depending on the Content Elements), contains TextMeshPro Text and should have max 2 lines

Content: should resize/scale depending on its content which has a fixed size, content 1 and 2 have fixed size (maybe i should use a vertical layout group here too?), depending on if this is larger than the header, the header should also resize its width

Button: should have a fixed size of 50x15 with a text inside

Image:enter image description here

Could someone please help me implement this UI? I would appreciate it a lot. Thank you in advance!

Upvotes: 1

Views: 93

Answers (0)

Related Questions