Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity UI Scrollrect and adding a list of items to it

Discussion in 'UGUI & TextMesh Pro' started by lovemoebius, Feb 19, 2019.

  1. lovemoebius

    lovemoebius

    Joined:
    Dec 12, 2016
    Posts:
    88
    This is making me go absolutely crazy, I'm trying to have a scrollrect and to populate it via script but for some reason it refuses to start adding my items from the top of the screen.

    Here's my setup


    MainMenuTest is pretty straight forward, just stretches to the size of the canvas.


    Scrollrect is also fairly simple, it contains the scrollrect, also stretches to the edges of the screen. Content is set to the gameobject that contains all my content, viewport to the viewport.


    Here's viewport


    And here's Sites, which contains all my menu gameobjects


    Notice how Pos Y is not 0. I cannot modify that, anything I change it to will be changed back to that number, meaning that my items will always start from the center of the screen and will look like this:



    My items are essentially added from the middle of the screen and expand from there, I would like for them to be added from the top and expand towards the bottom.

    How can I solve this?
     
  2. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,096
    change the pivot Y of the Viewport and / or Sites (a.k.a. Content) to 0 or 1.
     
  3. lovemoebius

    lovemoebius

    Joined:
    Dec 12, 2016
    Posts:
    88
    Truly feeling like an idiot, had no idea it was that simple.

    Thank you so much for your help!