Wednesday, October 19, 2022
HomeGame Developmentc# - Learn how to stop Unity's ScrollRect from shifting as the...

c# – Learn how to stop Unity’s ScrollRect from shifting as the scale of the content material adjustments?


I am writing a Textual content-RPG and I’ve arrange a ScrollRect the place new paragraphs and decisions are added and eliminated at each flip. This makes the scale of the Content material change consistently, which I deal with with a Content material Dimension Fitter.

To stop the participant from dropping observe of the final paragraph he was studying earlier than making a selection, I might prefer to preserve it in the identical place relative to the display screen it doesn’t matter what adjustments within the Content material. Nevertheless, this isn’t potential because of the clamped setting of the ScrollRect’s Motion Kind. I wish to preserve the clamped conduct to forestall limitless scrolling, however I must discover a technique to make it work whereas preserving the final paragraph’s place.

Here is a visible illustration of what I am attempting to attain:

Current Behavior (Wrong)
Desired Behavior (Correct)

Setting the ScrollRect’s Motion Kind to unrestricted causes the conduct I am searching for. Nevertheless, I can not permit the content material to be scrolled endlessly. If there’s a workaround for clamping an unrestricted ScrollRect that may very well be an answer… I might love to listen to about it!

I’ve additionally thought-about instantiating an empty block that takes the scale of the alternatives block to cowl the area marked in pink. Nevertheless, that causes extra issues because the participant may choose a selection whereas the scroll shouldn’t be totally on the backside. I actually do not know make that work.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments