Author Topic: Widget size in pixels  (Read 3797 times)

Markov

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Widget size in pixels
« on: October 10, 2013, 03:05:11 PM »
Hello. In new NGUI I can't get widget size in pixels.
I tried myWidget.localScale, all reloads of NGUIMath.CalculateRelativeWidgetBounds(), myWidget.width/height, all corners of myWidget...
I changed resolution of screen so the size of widget changed too(from very little to very big). And problem is that in code shows me that myWidget.width = 150 and height = 150 in ANY resolution and size of myWidget (all in editor mode)
How can I get actual size in pixels now?
« Last Edit: October 11, 2013, 07:00:59 AM by Markov »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Widget size in pixels
« Reply #1 on: October 11, 2013, 08:28:48 AM »
Widget size won't change if you change the screen resolution. Not unless you have a stretch script on it. Widget size is always specified in pixels, and whether your screen is 1920x1080 or 640x480, a 150x150 pixel widget will always be 150x150.

If you're changing the UIRoot's manual height, then you need to take UIRoot.pixelSizeAdjustment into account.

Markov

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: Widget size in pixels
« Reply #2 on: October 11, 2013, 10:39:33 AM »
Thanks, it works.
I request this feature in UIWidget. It's very handy :)