Author Topic: UIGrid  (Read 82635 times)

crust

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIGrid
« Reply #45 on: December 09, 2014, 06:54:27 PM »
yep  :D

amraffay

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 37
    • View Profile
Re: UIGrid
« Reply #46 on: May 05, 2015, 01:13:03 PM »
Hi there,
Currently we have to give fix column/row numbers to Grid, what if?

we apply anchors to grid, and grid automatically use the needed column/rows, so if i see it on mobile it shows 2 columns if i see it on desktop it shows 10 columns.

One more question is currently we have to give fixed size column sizes, i know table uses variable size, but instead of we giving size to grid, grid could use the size based on children?

Regards

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIGrid
« Reply #47 on: May 05, 2015, 10:50:27 PM »
The grid component is very simple. It has no dimensions, and there is nothing to anchor. Likewise the columns/rows remains a fixed number. Nothing is preventing you from writing a script that will adjust the grid's number of columns/rows then calling Reposition() on the grid though.

amraffay

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 37
    • View Profile
Re: UIGrid
« Reply #48 on: May 06, 2015, 12:31:46 AM »
but an update for something similar'd be great for noobs like me.

Dune

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: UIGrid
« Reply #49 on: October 21, 2016, 12:49:46 AM »
People for the last two years have asked for an align / anchor for the grid, and I've seen the replies, that UIGrid has no positioning. And that is true, it doesn't. But the GameObject it is loaded into does. Should I instead AddComponent the UIGrid onto the same GameObject as the UIScrollView? (edit: tried this, it didn't work)

When I run the game normally, it is fine, but when I resize the game window to maximum the grid pops off the Scroll View and all my items are hidden. If then in the scene view I grab the arrow control (W) and drag the grid's GameObject back to the scroll view, I can see my items. Since I have to use W to move the grid, it appears it has alignment.

What is the right solution?

Edit - Maybe found a solution, but now I can't scroll the scrollview...

Added a widget as a child of the Scroll View. Widgets have Anchors.
Then added the grid's GameObject as a child of that. Moved it to the desired position.
Removed the grid.Reposition() I was calling in script and the sv.ResetPosition() I was calling before and after the AddChild instantiates.
Run & Resize, the grid stays anchored in place.

« Last Edit: October 21, 2016, 04:23:33 AM by Dune »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIGrid
« Reply #50 on: October 24, 2016, 07:15:51 AM »
Yeah that's a good approach. All widgets have anchors, while the grid just repositions children. If the grid's parent is anchored, the grid itself will appear anchored using the pivot point of its parent.

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Re: UIGrid
« Reply #51 on: July 04, 2017, 12:51:11 PM »
What is the purpose of UIGrid.ConstrainWithinPanel()?

If the UIGrid only repositions objects, then I don't know how it'd also constrain to a panel, and though I see the code I can't figure out what it's actually supposed to do.
I thought this would change the grid size or limits to fit it in the dimensions of the parent panel, or ideally work with Cell Snap to fit all the elements within the panel, but it seems to have no effect whether it's on or off.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIGrid
« Reply #52 on: July 06, 2017, 06:30:27 AM »
IIRC it calculates the dimensions of the grid's content and positions the grid so that the contents fit within the panel's bounds, or at least positioning it so that the grid is aligned in the panel's top left corner. It's basically just an alignment tool.