Scroll Rect auto scroll over time?

Hey everyone, I’m trying to figure out how to access the “value” float on a slider for a scroll rect so that I can write up a quick script to make it auto-scroll. Anyone know how I can do that?

Since I haven’t seen a response, Does anyone have any idea how to auto scroll via some other method? I’m open to suggestions.

Hi @Twanner

I have no idea what is the correct way to do this, but ScrollRect content is just a regular RectTransform.

I don’t think you have to involve slider into this.

You could use: scrollRect.content.localPosition. If you have setup ScrollRect Movement Type to Clamped, this movement will still be clamped. So for example, some sin movement in y-axis will be clamped to panel ends even if it’s values would move it past allowed limits:

var pos = new Vector2(0f, Mathf.Sin(Time.time * 10f) * 100f);
scrollRect.content.localPosition = pos;

If you want to move content using 0-1 normalized position values, then there is ScrollRect.normalizedPosition, this will move the content directly between it’s end points AFAIK.

3 Likes

Thanks eses! That works perfectly!