Author Topic: Get current screen/panel/root width?  (Read 5146 times)

ajdickson1208

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Get current screen/panel/root width?
« on: September 06, 2014, 03:45:48 AM »
I need to find the width of the current NGUI screen/panel/root resolution, please help me with the code? I don't think it's just Unity's screen.width, but maybe something to do with that NGUI root's scaling by 2 / ScreenHeight?

I'm trying to tween an object back and forth depending on the button you press, but if you press both the button too fast, the object gets offset because it begins tweening the other direction before finishing the current tweening. I'd like to keep it that way so that players are able to toggle it quickly instead of waiting for the tweening to stop.
So I'd thought I'd make my script verify the position of the object before tweening in order for it to be in the right position, but since it can be played in different screen resolution, I do not know the solution to obtaining the current NGUI screen/panel resolution that matches my object/sprite's transform.localPosition.

Thanks for reading and sorry for my poor writing skill, hopefully someone could help me out here.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Get current screen/panel/root width?
« Reply #1 on: September 07, 2014, 08:26:14 AM »
UIPanel.width, UIPanel.height.