Author Topic: UIAnchor / UIStretch pixel size  (Read 3034 times)

mjost

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
UIAnchor / UIStretch pixel size
« on: November 15, 2013, 03:40:50 AM »
Hi everyone.

I use a fixed height design resolution by setting the UIRoot's manual height. Now when I set the 'Pixel Offset' of the UIAnchor or the 'Border Padding' of UIStretch, these values are interpreted in realtime as pixels. What I want is to define these values in relation to the design-res-height/screen-height ratio. So that the resolut looks the same on any resolution, meaning e.g. that a border padding of 10 should always be the same proportional distance. For example when I set the design height to 1080 pixels and the screen resolution height is 1080 pixels, then a border padding of 10 should be exactly 10 pixels. But if I set the design height to 1080 and the screen height is 720, then these 10 pixels of border padding should become 10 * (720 / 1080).

Is there any way of achieving such a behaviour that I don't know of?

Hope that was understandable...

Thanks!

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIAnchor / UIStretch pixel size
« Reply #1 on: November 15, 2013, 04:04:16 AM »
Yeah, the "pixel" refers to the virtual pixels that NGUI uses based on UIRoot's height. There's no way of converting it, save doing a manual hack for it.

The math is pretty simple - you know the Screen.height and the UIRoot.activeHeight - multiply the factor with the pixel offset and you have the new virtual pixel offset.