Author Topic: NGUI visibly scales on scene load, when swapping manual height  (Read 13931 times)

yahodahan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Looking for a workaround to this-

Currently, our game uses "manual" height and a screen-size based switch, so that on scene load, the "height" is set to either 768 or 640 (iPad or iPhone).  This works great with our current setup, except for one problem: when the scene loads, you can see the GUI quickly scale to the newly set height.

Is there a way to get around this? I was thinking, but not sure how, perhaps I could "reach into each scene" from a start/loading screen, and set the manual height before the scene is loaded?

However, that's a non-NGUI method, is there a way any one could recommend to get around this? Thanks much!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #1 on: August 27, 2012, 12:33:03 PM »
Call UIPanel.Refresh() after changing the size.

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #2 on: August 27, 2012, 04:09:53 PM »
Is there any way to accomplish this for all NGUI objects without having to call every UIPanel instance in the UI?

yahodahan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #3 on: August 27, 2012, 06:09:10 PM »
I was just about to ask the exact same thing!

Currently, I assume this must be called on every panel that is showing? I suppose "Refresh()" could be added to the "Awake" function of UIPanel, but I assume there is a good reason that isn't already there...?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #4 on: August 27, 2012, 06:23:46 PM »
NGUITools.Broadcast("Refresh");

or the faster way affecting only the UI:

UIRoot.Broadcast("Refresh");

yahodahan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #5 on: August 27, 2012, 10:45:58 PM »
Thanks, I tried this, but still having the issue- here's a quick video:
https://www.dropbox.com/s/7ywd0o6sj83be3h/uiScaling_01.mov

Any other thoughts? Much appreciated!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #6 on: August 28, 2012, 02:39:25 AM »
I'm not sure I'm seeing the issue. As a sidenote, in Windward all my UI is positioned at 1400 along the Y, basically ensuring that it first appears off-screen.

yahodahan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #7 on: August 28, 2012, 12:37:31 PM »
The issue is, the very fast scaling/sliding effect that happens just as the scene swaps, and the new ui appears. The effect isn't intentional :P

The root of the cause is that the UIRoot manual height is set to "640" (for iOS handheld), in every scene. Then, in the "Awake" function of a script in the scene, I check the screen height of the device, and set to 1024 if needed (iPad).

So, it works just fine for iPhone/etc, but on the iPad it does a that funky/unwanted quick-scale right on load. Maybe I'm just using the system wrong, but it seems there ought to be a way around this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #8 on: August 28, 2012, 03:37:09 PM »
Simple solution: have your UI start disabled (but leave UIRoot enabled), then enable it in a Start function that's attached to the same object as UIRoot.

yahodahan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #9 on: August 28, 2012, 03:54:04 PM »
So, just disable each UIPanel, then enable upon start? Just making sure I understand properly. Thanks much!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #10 on: August 29, 2012, 09:07:49 AM »
Yup. In Windward I actually have most of my UI disabled (as I have many different windows -- settings, summary screen, etc), and enable it selectively when needed.

yahodahan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #11 on: August 30, 2012, 11:45:48 AM »
This is changing topics somewhat, but I'll just continue here-

I went your way, and just made one big GUI, with the panels swapping when switching to a different "screen". So I'm turning the panels on/off, however the buttons/etc in each panel naturally still remain active.

I figured I could simply move the non-active panels away, but they all have at least a couple anchors inside them, then all the elements, so I am unable to move them at all. What is the best way around this? Turning the anchor scripts on/off when moving? That seems likely to cause trouble, and would be a lot of anchors as well. Seems like there must be a better way :)

yahodahan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #12 on: August 30, 2012, 11:54:08 AM »
Maybe just to make that more clear:

My UI tree goes like this
-UI Root (2D)
   -Camera
      -StartScreen
         -Anchor_Bottom
             -visuals/btns/etc
         -Anchor_Top
             -visuals/btns/etc
         -Anchor_Right
             -visuals/btns/etc
       -SettingsScreen
          -More anchors, etc
      -And so forth...

I have a feeling this is fairly standard, what I'm trying to do, but am not seeing the method...I'd just like to move around the top level panels (ie, "StartScreen" or "Settings")

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI visibly scales on scene load, when swapping manual height
« Reply #13 on: August 30, 2012, 04:38:06 PM »
Anything above an anchor can't be moved. You should create your windows under the anchors, not above.