Author Topic: proper anchoring of grid with elements  (Read 1795 times)

pretender

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 155
    • View Profile
proper anchoring of grid with elements
« on: September 10, 2014, 07:12:44 AM »
Can somebody help me in order to get anchoring properly for gird that is full of elements and needs to be centered properly (problem arises when using resolutions like 1024x768)

check out the picture!



1.) need that grid at the given distance from the edges (centered) but elements inside scaled properly
2.) there will be rows of grids not just one, how to anchor those?
3.) is it Fixed size way to go?

here is the setup i tried:
UIRoot
 Panel
  widget (anchors to UIRoot -> uniform)
    grid (anchors to widget -> uniform)
     [elements]

elements and grid doesn't scale but there is a overflow.
thanks!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: proper anchoring of grid with elements
« Reply #1 on: September 11, 2014, 01:35:22 AM »
Grid can't be anchored. Grid is just a component that re-arranges child game objects, so I don't understand what you mean by anchoring the grid, and how your diagram has it anchored to a widget. Your image link is also broken.

pretender

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 155
    • View Profile
Re: proper anchoring of grid with elements
« Reply #2 on: September 22, 2014, 07:54:49 AM »
Hi! Here is the new image http://imgur.com/So1nxcj

I will try to explain in detail what i want.
Border of the image is device screen dimensions, whatever screen resolution currenly is. The red square is the widget that should be always centered and anchored. Inside red square there will be arrays of sprites (yellow) that should be somehow scaled to keep original aspect ratio (i put white squares as a containers for yellow sprites because it seemed like a good idea)

the closest example of what i am trying to do is to have a layout similiar to periodic table of elements (here is a image reference: https://www.google.rs/search?q=periodic+table+of+element&client=firefox-a&hs=yv4&rls=org.mozilla:en-US:official&channel=sb&tbm=isch&imgil=0rRKFpPGSHhCHM%253A%253Bn1nStMiYO3a_AM%253Bhttp%25253A%25252F%25252Fblog.askiitians.com%25252Fback-benchers-tip-learn-periodic-table%25252F&source=iu&pf=m&fir=0rRKFpPGSHhCHM%253A%252Cn1nStMiYO3a_AM%252C_&usg=__tgfdrHR4IqPw8EC3yldmWqKhCII%3D&biw=1680&bih=978 ) but to be flexible in regards to screen resolution ( i tried to solve this before by hard coding UIRoot parameters for example Ipad 2's resolution (1024x768) to accommodate its 4:3 ratio, I would like to avoid this sorts of things. Sprites also need to maintain its original aspect and not distort.

This seems like a somewhat complicated setup so I need some help!
Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: proper anchoring of grid with elements
« Reply #3 on: September 22, 2014, 10:31:23 AM »
Alright, in that case you will need to at least dynamically adjust the cell width/height based on the width of your red widget. Remember, UIGrid has no concept of flexibility. It's something you'd need to add using some code logic, meaning a custom script.