unity3d gui - Creating a flexible UI contianer for an image and a label -


i thought pretty simple task do, have tried hours , cant figure out how around this.

i have list of friends should displayed in scrollable list. each friend have profile image , name associated him, each item in list should display image , name.

the problem cant figure out how make flexible container contains both image , name label. want able change width , height dynamically image , text scale , move accordingly.

i using unity 5 , unity ui.

i want achieve following container:

  • the width , height of container should flexible
  • the image child of container , should left aligned, height should fill container height , should keep aspect ratio.
  • the name label child of contianer , should left aligned image 15 px left padding. width of text should fill rest of space in container.

hope illustrated in following attached image:

enter image description here

i asked same question here on unity answers, no answers far. possible such simple task not doable in unity ui without using code?

thanks lot time!

looks can achieved layout components.

the image child of container , should left aligned, height should fill container height , should keep aspect ratio.

for try add aspect ratio fitter component aspect mode - width controls height

enter image description here

the name label child of container , should left aligned image 15 px left padding. width of text should fill rest of space in container.

for can anchor , stretch label container size , use bestfit option on text component

enter image description here


Comments