Author Topic: Determining UIGrid current height (or dimensions) to fit a background  (Read 4165 times)

1337GameDev

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 13
    • View Profile
I have a grid as a child of a scroll list, and I will dynamically add items to the grid and call reposition on the grid, but I also want a background UISprite to grow with the grid.

 How do I get the height of a grid, to be able to fit my background to cover the grid area?
Do I have to count the number of grid elements, and calculate how long it is based on the cell height and such? I want to avoid this, as it seems hard to get perfect, and I am unsure how to get grid spacing amount.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Determining UIGrid current height (or dimensions) to fit a background
« Reply #1 on: December 22, 2013, 07:39:17 AM »
Hmm, I don't think UIGrid knows anything about the total sizes directly like that.

You might be able to use the NGUIMath.CalculateAbsoluteWidgetBounds on the parent, since that takes children into account - but that might give you the FULL size.

I suppose you can also make the parent a sprite and have that follow that way with the new anchor/stretch system.