Search Unity

Dynamic Positioning relative to new objects.

Discussion in 'Scripting' started by m_danish_s, Sep 2, 2014.

  1. m_danish_s

    m_danish_s

    Joined:
    Sep 2, 2014
    Posts:
    13
    HI,

    I have been searching about this issue on different forums, but couldn't find an exact answer, not even close to hint to do some thing as follows:

    I want to create a scrollable list using new unity UI, what I want to do is to get some data (the menu items), menu items consists of two elements a background image and a text (displayed on that background). The text can vary in length.

    So I want to create these menu items dynamically, i.e. during runtime. Hierarchy will be as follows

    -Panel
    ----Panel
    ------Background Image
    ------Text
    ----Panel
    ------Background Image
    ------Text
    ----Panel
    ------Background Image
    ------Text

    for this I have to set the height of background image and panel during runtime. I will use the first panel (the grand parent panel) to achieve scrolling.

    While playing with this, I tried to access width and height of panel using script, but wasn't able to do so. Is there another way to achieve this? Or if I am going right, how can I set my menu items dynamically (i.e. access width and height through script) to increase height of the panel and images dynamically?
     
  2. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
  3. m_danish_s

    m_danish_s

    Joined:
    Sep 2, 2014
    Posts:
    13
    Ok, thanks I am putting it there too.