Author Topic: Generate UIGrid to fit a Panel/Screen?  (Read 1052 times)

Trithilon

  • Guest
Generate UIGrid to fit a Panel/Screen?
« on: November 08, 2012, 07:04:01 AM »
Hello,
I am trying to make a simple grid based puzzle game.
The grids in my game need to be resolution independent - is it possible to fill the entire screen or panel with the contents of a grid dynamically?

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Generate UIGrid to fit a Panel/Screen?
« Reply #1 on: November 08, 2012, 01:59:06 PM »
Knowing the size of your cells and the size of your screen, instantiate the appropriate number of entries.

Trithilon

  • Guest
Re: Generate UIGrid to fit a Panel/Screen?
« Reply #2 on: November 08, 2012, 03:15:36 PM »
And how would I come to know of the size of my widgets?
Once they are under a parents, its hard to determine that...

Also, is there any limitation to what things about the grid will scale with the UI Height?

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Generate UIGrid to fit a Panel/Screen?
« Reply #3 on: November 09, 2012, 04:52:27 AM »
You said you use a grid. Grid size is constant. Even if it wasn't, you can always use NGUIMath.CalculateWidgetSize (or was it in NGUITools? I'm away from my PC atm)

You should ideally create your own grid system instead of using UIGrid since you want it to resize based with the size of the screen.

NGUI can handle all the visualization, but it's up to you to create logic that positions your widgets how you want them.