Page 1 of 2

How do I shrink a Response Button Template?

Posted: Sat Aug 24, 2019 4:01 pm
by AoF


The Response Button Template is too large for me (vertical space), but whenever I try to make it smaller, Unity puts it back to where it was. I think this is because of layouts, but I can't figure out which component is setting the size.

Hierarchy:

Content:

Response Button Template:

Response Text:

I would have assumed this is controlled by the Layout Element, but changing the Min Height has no effect.

Re: How do I shrink a Response Button Template?

Posted: Sat Aug 24, 2019 9:43 pm
by Tony Li
If you don't expect to have more than 5 responses at any given time, the easiest way to set it up is to turn off the scroll rect:

1. Inspect Response Menu Panel. Deactivate the Scroll Rect component.

2. Inspect Content. Change the Rect Transform to this:

mgfContent.png
mgfContent.png (18 KiB) Viewed 1621 times

Re: How do I shrink a Response Button Template?

Posted: Sat Aug 24, 2019 10:05 pm
by AoF
I think it's more likely than not that I'll have more than 5 and will need to use that scrollbar. I think that already comes up a at least once in my current code.

Is there a way to shrink them if I still want to use a scroll bar?

Re: How do I shrink a Response Button Template?

Posted: Sat Aug 24, 2019 10:13 pm
by Tony Li
Actually that's exactly the same. Just re-enable the Scroll Rect.

Re: How do I shrink a Response Button Template?

Posted: Sat Aug 24, 2019 10:17 pm
by AoF
That in it of itself did not make the content smaller. It just seemed to move it to the bottom:


Re: How do I shrink a Response Button Template?

Posted: Sat Aug 24, 2019 10:21 pm
by Tony Li
Oh, I thought you wanted to make the entire response menu panel smaller. Sorry I didn't read that correctly.

Check the Response Text. If it has a Layout Element, you may need to reduce its Min Height.

Then check the same for Response Button Template.

Finally, check the Content's Vertical Layout Group. Make sure Child Force Expand > Height is not ticked, since this may try to make the content tall enough to fill out the entire viewport height.

Re: How do I shrink a Response Button Template?

Posted: Sat Aug 24, 2019 10:42 pm
by AoF
Unless I'm misunderstanding something, I think my pictures show it already doing all those things. Reducing the layout group's min height makes no difference.

Re: How do I shrink a Response Button Template?

Posted: Sat Aug 24, 2019 10:49 pm
by Tony Li
What if you untick the Response Button Template's Vertical Layout Group > Force Expand > Height checkbox?

You might just need to play around with it. Feel free to send me a copy of the UI if you'd like me to take a look and see if I can find settings that make the buttons less tall.

Re: How do I shrink a Response Button Template?

Posted: Sun Aug 25, 2019 4:28 pm
by Tony Li
In the end, the key was to untick the Content GameObject's Vertical Layout Group > Control Child Size.

Re: How do I shrink a Response Button Template?

Posted: Sun Aug 25, 2019 4:32 pm
by AoF
Tony Li wrote: Sun Aug 25, 2019 4:28 pm In the end, the key was to untick the Content GameObject's Vertical Layout Group > Control Child Size.
Of course (???)!

I know this is more about Unity and your library, but does that make sense to you? I've been trying to learn how Unity layout works ever since I started learning Unity, and have never found a thorough resource. If you happen to know of one, I'd love to read it. I've always been confused by Content Layouts.