Author Topic: positioning UIGrid  (Read 2344 times)

Karel

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
positioning UIGrid
« on: January 22, 2014, 07:09:51 AM »
Hey,

I have a UIGrid component in my scene, but I have a hard time positioning it. It does not have an UIWidget, and therefore can't be properly positioned relative to the parent widget like all other widgets can. I can't attach an UIWidget through the menu's either, so I assume I am not supposed to.

When I add widgets to the UIGrid, they are centered in the parent grid because the UIGrid object is positioned at [0,0]. I want to be able to use the anchors to, for example, position the content of the grid on top of the parent widget.

Is this possible? Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: positioning UIGrid
« Reply #1 on: January 23, 2014, 07:04:28 AM »
UIGrid modifies the transform.localPosition of all of its children. The grid's position is its origin point -- all children are positioned to the right and below that point. Grid has no bounds, so there is nothing to anchor. It's just a positioning helper script. If you want to reposition the grid itself, use NGUIMath.Calculate series of functions to calculate the bounds of the grid, then adjust its position accordingly.