Author Topic: How to get NGUI to re-draw the UI when aspect ratio changes at run-time  (Read 2311 times)

Meltdown

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 56
    • View Profile
If I start my game, no matter the aspect ratio, NGUI will draw everything correctly, provided I am using Anchors correctly.
The problem we have now is in a Windows 8 app, the user can resize the game on the fly into windowed/snapped mode, so the aspect ratio changes.

What can we call in NGUI to make it re-draw everything so it displays correctly again, no matter how the aspect ratio is changed at run-time?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to get NGUI to re-draw the UI when aspect ratio changes at run-time
« Reply #1 on: January 27, 2014, 07:04:06 PM »
If you've used anchors, and set them to be attached to sides of the screen, then there should be no issue.

Provided you used the new anchor system, and not the old one. If you used the old one (UIAnchor), then your anchors may disable themselves after running their logic.

Meltdown

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 56
    • View Profile
Re: How to get NGUI to re-draw the UI when aspect ratio changes at run-time
« Reply #2 on: January 27, 2014, 08:22:36 PM »
This project I am working on uses the old anchor system.

Sorry, I'm not sure what you mean by the anchors may disable themselves? Does the UIAnchor script disable itself after being run once? And if it does should I re-enable it?


Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: How to get NGUI to re-draw the UI when aspect ratio changes at run-time
« Reply #3 on: January 28, 2014, 08:18:43 AM »
Yeah, reenable it when you get the event that rotation happens (I assume mobile) otherwise reenable it when the aspect changes, then it'll reposition everything and turn itself off again.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to get NGUI to re-draw the UI when aspect ratio changes at run-time
« Reply #4 on: January 28, 2014, 09:26:51 AM »
"run only once" is an option on the old anchor.