Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Paul5 on September 25, 2014, 04:19:29 PM
-
Hello,
I have a row of buttons that I want to anchor to the top of the screen. I've tried various methods including anchoring them to each other, anchoring them to the root etc. but none of them have produced the desired effect. I want them to be spaced evenly regardless of the resolution. Currently, however, the middle two buttons just get stretched out instead of spaced evenly. Any ideas?
Thanks
-
Use Advanced anchoring with Custom settings, specifying 0 for Absolute and some 0 to 1 value for the relative fields (the slider). For example 0.3 means 30% from the left if it's on Left/Right, or 30% from the bottom if it's on Top/Bottom.
-
Use Advanced anchoring with Custom settings, specifying 0 for Absolute and some 0 to 1 value for the relative fields (the slider). For example 0.3 means 30% from the left if it's on Left/Right, or 30% from the bottom if it's on Top/Bottom.
Thanks for the reply. I played with this for a bit and basically had the same results with a variety of methods. I want some blank space between the buttons when the resolution gets bigger, but when the buttons are anchored they always just stretch themselves instead of leaving some space. I've anchored them to the root, other buttons, some of both, and they all seem to have the same sort of behavior.
-
So I gave up on the anchors and decided to use a simple script instead. This accomplished the task, however, I seem to have a hard time with the constrained mode using my script. In the pixel perfect mode this script works fine, however, in constrained mode it doesn't (I'm guessing it has something to do with the resolution being different or something). Any ideas? Thanks.
http://pastebin.com/a6Es5SpR
-
You need to take UIRoot's pixelSizeAdjustment into account. When UIRoot is set to Constrained, it means its virtual pixels don't match your screen pixels, so you can't simply use Screen.width and height.
-
You need to take UIRoot's pixelSizeAdjustment into account. When UIRoot is set to Constrained, it means its virtual pixels don't match your screen pixels, so you can't simply use Screen.width and height.
That is what I needed.
Thanks!