Author Topic: Multi-Frame Pop when Eveloping Dynamic Content  (Read 593 times)

Terazilla

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Multi-Frame Pop when Eveloping Dynamic Content
« on: April 05, 2017, 03:25:47 PM »
We have a several UI elements that wrap a frame around dynamic content, and in all cases we're seeing a delayed visual pop when the dynamic content is resized.

One simple case is a window that contains a dynamic number of buttons and is centered on the screen. Here's what the object hierarchy looks like:

    "Window" (UIPanel)
        "Window Border" (UISprite with top and bottom anchored to "Content Border")
        "Content Border" (UISprite, EnvelopContent that targets "Content")
        "Content" (UITable with 1 column)
            Variable number of UIButtons


Essentially, the list of buttons has a border that envelops it. Around that is the larger window border. In the real game, we have UI elements that are anchored between to the window border, but they're omitted in this example as they're not needed to demonstrate the problem.

Here are the steps we follow in code when showing the window:

    Call NGUITools.SetActive(window.gameObject, true) with the window's GameObject.
    Create/activate/deactivate buttons as needed, hook up their OnClick events, etc.
    Call Reposition() on the content's UITable component
    Call Execute() on the content border's EnvelopContent component

Let's say the window was last shown with 5 buttons in it, and then hidden. Now I update and show the window with only 2 buttons, using the above approach:

    On the first frame, it'll appear with 2 buttons, and the "Content Border" sprite tightly wrapping it, but "Window Border" is too big and still sized for 5 buttons.
    On the next frame, "Window Border" will have adjusted down to properly fit around "Content Border". It's possible that the resize takes multiple frames, I haven't stepped through it frame-by-frame.

Generally speaking, this code is executing in response to an OnClick() event generated by NGUI, which we have happening in Update().

We've tried a bunch of things to try addressing this, but I keep coming up empty. Is there something that we're doing wrong?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Multi-Frame Pop when Eveloping Dynamic Content
« Reply #1 on: April 07, 2017, 06:02:23 PM »
Seems like the same question as here: http://www.tasharen.com/forum/index.php?topic=15213.0

Change your hierarchy. Move the window border and content border to be below your content, not above it.