Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

ScrollRect automatically scrolling on activation in beta 20?

Discussion in 'UGUI & TextMesh Pro' started by jareds, Oct 9, 2014.

  1. jareds

    jareds

    Joined:
    May 8, 2008
    Posts:
    207
    Hi,

    I recently upgraded my project from beta 16 to beta 20 and I'm having an issue with some of my content. I have a ScrollRect filled with text that now seems to automatically scroll the content to the bottom of the visible scroll area upon activating the GameObject. Does anyone know why this might be happening? I added a function to OnValueChanged on the ScrollRect to output the anchoredPosition of the content and it seems to indicate that the content thinks it is should be scrolling for some reason (anchoredPosition.y starts at my desired position and then moves down until the content is at the bottom of the ScrollRect).

    Thanks,
    Jared
     
  2. jareds

    jareds

    Joined:
    May 8, 2008
    Posts:
    207
    A little more information: if the content inside of the ScrollRect is larger than the rect, everything seems to behave properly. It is only if the content is smaller than than the ScrollRect that it suddenly decides to scroll to the bottom.
     
  3. jareds

    jareds

    Joined:
    May 8, 2008
    Posts:
    207
    For now, I've fixed this by disabling the scroll (ScrollRect.vertical) if the content has a height less than the height of the ScrollRect; it still seems like odd behavior though.
     
  4. RustyFlash

    RustyFlash

    Joined:
    Oct 8, 2014
    Posts:
    88
    I had the same problem. Somehow I fixed it by setting the scroll handle to a value of 1 when the ui containing it woke. It worked for me, though does appear to be odd behaviour.
     
    jareds likes this.
  5. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,870
    Since it's generally undefined how a ScrollRect behaves when the content is smaller than the view, the ScrollRect adds padding to the content to make it at least as large as the view. Where the padding is added depends on the pivot of the content. Pivot at the top adds the padding to the bottom, pivot in the middle adds padding on both sides etc.
     
    jareds likes this.