Search Unity

UGUI GridLayoutGroup Help

Discussion in 'UGUI & TextMesh Pro' started by will_brett, Jul 10, 2015.

  1. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Hey there,

    So I have been using NGUI for quite a while now but thought it's time to switch over to UGUI as I really love the Anchor system and snaps.

    Im having a bit of trouble converting my grid stuff.

    1. How do you do a reposition grid contents in UGUI at runtime through script like you can in NGUI?

    2. How do you add new items to grid at runtime. NGUI was NGUITools.AddChild.
    Thanks
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    2) just add the new item as a child, believe the sibling position dictates the position in the grid

    not sure what you mean by reposition in 1, i.e. change the order? or do you mean actually move around?
     
  3. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Thanks for the reply. I fixed 2 after writing this post using what you said above.

    So the reposition would reorder the grid items.

    For example with NGUI I would have the list in numeric order but adding a new item would just add it to the grid but the grid would not reorder the grid until you called grid.reposition();
     
  4. wpdev

    wpdev

    Joined:
    Jan 10, 2015
    Posts:
    8
    1) i found a way to update grid layout by changing starting corner and then setting back initial value

    grid.startCorner = GridLayoutGroup.Corner.UpperRight;
    grid.startCorner = initialValue;

    I believe there is a better way to do this and i would love to know how.
     
  5. will_brett

    will_brett

    Joined:
    Feb 16, 2013
    Posts:
    208
    Wouldn't grid.startCorner = initialValue do it on its own?
     
  6. wpdev

    wpdev

    Joined:
    Jan 10, 2015
    Posts:
    8
    No, it didnt work for me