Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: patch24 on June 24, 2012, 12:55:46 PM

Title: Button spacing techniques
Post by: patch24 on June 24, 2012, 12:55:46 PM
Hi, I know these kinds of questions have been asked ad-nauseum....I just wanted to see if anyone know the best way to do scaling of  button spacings depending on screen size.  I am talking about not doing pixel perfect atlas swapping...I realize that lower resolutions will look blurry, I just wanted to see if turning off automatic on the UIRoot would affect a row of buttons that should be equally spaced across the entire length of the top of the screen.  Is the idea to use UIAnchor to attach the main panel parent to the top of the screen, then let UIRoot stretch/contract the spacing of the panel with button children automatically, no matter the screen width change?  Or should each button somehow use a UIAnchor to keep themselves placed...? Maybe a UIStretch should be used? (i am away from my computer right or I would check it myselft)  Thanks!
Title: Re: Button spacing techniques
Post by: loopyllama on June 24, 2012, 02:56:08 PM
I suppose it depends where the buttons are located. For instance my level buttons are all under the same anchor, set to center. My "back" button is on the lower left, so it has it's own anchor parent set to bottom left with a relative offset in x and y. works great on iPad and iPhone for my universal app.

As your resolution/aspect ratio changes you have to decide where each button should offset itself from...that will determine how many different anchors you need...
Title: Re: Button spacing techniques
Post by: Nicki on June 24, 2012, 05:11:24 PM
There's no magic formula for it. You have to determine the total width of your screen and place your buttons accordingly.

If you leave UIRoot on automatic, then it will place it with the same offset, but based on height - so if the height changes, the placing changes respective to that. If you leave it on manual, then widgets below it will place with "pixels" the size of your manual setting, which may be off from the real pixel size. Changing from 400 height to 600 height in the real screen resolution, would make it so localpositions would translate to 1:1.5, so every time you move your widgets 1 localPosition, you move it 1.5 realpixels (likely making it fuzzy, but that's a different matter).

It is a relatively simple matter to just place it, assuming you make your UIRoot's manual height the real size. Even if you don't it's still just a matter of a little math. :D