Search Unity

HorizontalScrollSnap set page programatically

Discussion in 'Editor & General Support' started by ohthepain, Sep 23, 2021.

  1. ohthepain

    ohthepain

    Joined:
    May 31, 2017
    Posts:
    58
    I am looking for a way to programatically scroll to the next or previous page of my HorizontalScrollSnap.

    I tried

    Code (CSharp):
    1. horizontalScrollSnap.CurrentPage = 2;
    but it had no effect.

    The context is a battle menu that shows the waves of enemies. Each wave is one page. I have successfully populated the scroll view and the snapping works when I scroll with my finger.

    The goal is to scroll to the next page every second so that the user can see them automatically scrolling by. Each second or so it will automatically and smoothly scroll to the next page. I think this will add some energy to the menu.

    I'm guessing that there is a solution somewhere that would allow adding buttons to go back and forth between the
     
unityunity