Author Topic: Updating before displaying?  (Read 3528 times)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Updating before displaying?
« on: June 17, 2012, 09:36:34 PM »
I have a problem now where when I first create my menu. There is about a 0.25 delay before it correctly adjusts to its proper size.

I am using

GameNGUI.GetComponent<UIRoot>().automatic = false
GameNGUI.GetComponent<UIRoot>().manualHeight = Screen.currentResolution.height;

but there is a noticable delay before the menu gets resized properly. Is there anyway to easily stop the menu from appearing on screen until it has been resized?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Updating before displaying?
« Reply #1 on: June 17, 2012, 09:49:49 PM »
That's likely a single frame delay. You can broadcast "Refresh":

  1. NGUITools.Broadcast("Refresh");

Or, the faster method, if you know which panel you want to refresh:

  1. panel.Refresh();

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Updating before displaying?
« Reply #2 on: June 18, 2012, 02:10:59 AM »
Or if you're hardcore, you can call it directly from a widget:

  1. myWidgetReference.panel.Refresh();

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Updating before displaying?
« Reply #3 on: June 18, 2012, 04:21:43 AM »
Thanks guys. That did the trick :)

I've been looking at that slight resizing issue for well over a month now and I kept thinking, I am going to fix that one day. And then just pasting "NGUITools.Broadcast("Refresh");" after my instantiate and it suddenly works. Great stuff thanks :)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Updating before displaying?
« Reply #4 on: June 19, 2012, 12:51:48 AM »
Hmm, annoyingly the problem still exists on handheld devices. Just seemed to fix it on PC and Mac only. :/