P
P
Pychev Anatoly2020-08-01 22:27:29
Unity
Pychev Anatoly, 2020-08-01 22:27:29

How to programmatically slide the content of a ScrollView?

Hello.
It is necessary to make a smooth scrolling of the ScrollView content by clicking on the button.
Now it works like this

public void NavButtonDown_Click(){
        StartCoroutine(ScrollToTop ());
    }
    public void NavButtonUp_Click(){
        StartCoroutine(ScrollToBottom());
    }
    IEnumerator ScrollToTop ( )
    {
        yield return new WaitForEndOfFrame ( ) ;
        Scrollview.GetComponent<ScrollRect>().verticalNormalizedPosition = 1f ;      
    }
    IEnumerator ScrollToBottom ( )
    {
        yield return new WaitForEndOfFrame ( ) ;
        Scrollview.GetComponent<ScrollRect>().verticalNormalizedPosition = 0f ;      
    }

But there is an abrupt shift.
Tell me how to make a smooth shift.
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2020-08-02
@aDOPPIO

Of course, I'm not a craftsman, but isn't it possible to produce Lerp? In advance, I apologize if I'm stupid.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question