#Reactive scroll rect

1 messages · Page 1 of 1 (latest)

glad dagger
#

What's the best way to make a scroll rect reactive to different resolutions (landscape and portrait)? Trying to work out if setting the flexible width on the layout element works but I can't work out if it's even doing anything?

#

I just found a question about this exact issue on the unity forums which got not even a single response 🥲

autumn sorrel
#

Can you describe it with more information? The scroll rect can change size as normal and if the content uses anchors then that can also change too.
e.g. a vertical only scroll rect can have its content anchors be fully separated horizontally to resize with viewport.

glad dagger
autumn sorrel
#

For what, the whole scroll rect or just the content?

#

You can use the left, right, top, bottom offsets in rect transform to have there always be some px gap from the anchors

glad dagger
glad dagger
autumn sorrel
#

If you look at the ScrollRect component you can see what "Content" is

glad dagger
#

Ah yeah

#

On the content then

autumn sorrel
#

You can try this:

#

Where content is setup like:

#

If you need height resizing to fit content then this can be done with layout groups

glad dagger
#

Height I'll need to work out as it scrolls on/off page. Mostly works for click and drag kinda, doesn't work at all for controller

glad dagger
autumn sorrel
glad dagger
#

But how can I manually set the anchors?

#

I should specify, 2021.3 incase it's changed in newer versions

autumn sorrel
#

Click and drag them in the scene view

#

you are not forced to only change it via the rect transform inspector

glad dagger
#

The blue corners? But that's the size isn't it?

autumn sorrel
#

The white triangles

glad dagger
#

I don't have those 🤔

autumn sorrel
#

Make sure gizmos are visible in scene view

glad dagger
#

How?

#

I thought those were on by default so I don't think I've ever gone looking for the option lmao

#

Oh just that button, yeah it's on

#

Yeah it's all on, but no anchor points

#

.... It's cause the object was inactive

#

Why can the size/position be changed but not the anchors 😭

#

Weird, I can only stretch it up/down, and not to the sides

#

Oh I can but it snaps back?

glad dagger
#

Managed to just do all of this by adding padding to the grid layout group

autumn sorrel
#

You may have changed your gizmo settings to hide the anchors in scene view but if its working then good