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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Solved]ScrollList and insert top to of list

Discussion in 'Scripting' started by opwallin, Nov 6, 2015.

  1. opwallin

    opwallin

    Joined:
    Dec 27, 2013
    Posts:
    17
    I've follow Unity lesson which focused scrollist made by scrollrect and panel component and which uses buttons as content. However, how I can add new delegates on top of list ?
    Code (CSharp):
    1.         GameObject newDelegate = Instantiate(rduCloseButton) as GameObject;
    2.         rduDelegate rdelegate = newDelegate.GetComponent<rduDelegate>();
    3.         var src = reporta.m_issuedTime.ToString(format);
    4.         rdelegate.m_timeLabel.text = src;
    5.         rdelegate.m_reportTitle.text = reporta.m_title;
    6.         if (contentPanel != null)  {            
    7.                newDelegate.transform.SetParent(contentPanel, false);
    8.         }
    This will add new delegates (aka buttons) to end of list.
    .
     
  2. tranos

    tranos

    Joined:
    Feb 19, 2014
    Posts:
    180
    You can add a "vertical layout group" component to your parent object of your buttons and change "child alignment" to "lower center".
     
  3. opwallin

    opwallin

    Joined:
    Dec 27, 2013
    Posts:
    17
    Wont work ...
     
  4. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  5. opwallin

    opwallin

    Joined:
    Dec 27, 2013
    Posts:
    17
    It helped, thanks.