Author Topic: Expanding elements in a UIGrid  (Read 4297 times)

DZP

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 17
    • View Profile
Expanding elements in a UIGrid
« on: November 07, 2013, 10:28:06 AM »
Hey there,

I am working on making a UIGrid with expanding elements for a shop interface. Simply you click on one of the elements in a vertical shop and the image expands down and reveals more information.

I have an extended UIGrid that can have cells with different heights but I'm having problems with the bounds of the UIGrid. I can see the bounds dictated by the orange box in the editor. When I change the sprite height of an element in the grid the bounds goes all silly. I have demonstrated this by the 2 screenshots.

I looked in UIGrid.cs and could not see how the boundaries are being set. Could you please point me in the right direction or would I be better off writing my own Grid class to manage a collection of elements with dynamic sizes?

Thanks in advance. Forgive the lovely placeholder images....

EDIT: I am using the latest version of NGUI with Unity 4.2

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Expanding elements in a UIGrid
« Reply #1 on: November 08, 2013, 10:20:38 AM »
Have you looked at UITable? Because that's exactly what it does -- lets you resize content elements while still keeping them positioned.

Look at the quest log example.

DZP

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: Expanding elements in a UIGrid
« Reply #2 on: November 08, 2013, 10:34:11 AM »
Have you looked at UITable? Because that's exactly what it does -- lets you resize content elements while still keeping them positioned.

Look at the quest log example.

Thanks, that's saved me some time! Why does UIGrid not have the same functionality out of curiosity?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Expanding elements in a UIGrid
« Reply #3 on: November 08, 2013, 10:44:20 AM »
Because UITable is a lot slower than a UIGrid.