Search Unity

ScrollView reset to original position?

Discussion in 'Scripting' started by nbfp, Jan 14, 2020.

  1. nbfp

    nbfp

    Joined:
    Jul 30, 2015
    Posts:
    23
    Hi,

    I have Unity's Scroll View on canvas. All I am trying to do is reset scroll view's content position from script to it's original position. I have searched for an answer, but nothing seems to work. Scaling goes haywire, content object moves etc. There must be something really simple that I am missing, but getting really confused now.

    If it makes any difference:
    I have set content object's anchor and pivot point to left top corner.
    Content object's size is set manually (it is always filled with same size content)
     
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    ScrollView which is a part on the new UIElements.
    Code (CSharp):
    1. scrollView.ScrollTo(scrollView.ElementAt(0));
    ScrollRect which is part of uGUI.
    Code (CSharp):
    1. scrollRect.verticalNormalizedPosition = 0;
     
  3. nbfp

    nbfp

    Joined:
    Jul 30, 2015
    Posts:
    23
    Thank you Chris-Trueman. Worked wonderfully. I had tried verticalNormalizedPosition, but tried to apply it to the content object (child of ScrollView), and not to ScrollView itself:confused:. Knew that I just had some basic misunderstanding.
     
    Chris-Trueman likes this.