Author Topic: UIPanel disappears after scrolling  (Read 10046 times)

Dennis_N

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
UIPanel disappears after scrolling
« on: January 30, 2014, 04:29:42 PM »
I've set up UIPanel with UIScroll View and restrict within panel checkbox enabled to keep it always in view.
When I enable any kind of clipping, the panel disappears after a couple of strokes.
If I disable clipping, that doesn't happen anymore.
What is the problem?

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #1 on: January 30, 2014, 07:05:19 PM »
yeah, i'm getting such issues of content inside scrollviews getting invisible in between while not scrolling, too, since i updated to one of the most recent versions, looks like something went buggy there :I

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #2 on: January 31, 2014, 12:16:57 PM »
Can you give me steps to reproduce the issue in the latest version?

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #3 on: January 31, 2014, 01:07:32 PM »
sadly can't since i'm not sure yet what exactly makes this happen.
I just see:
-It happens for several but not all of the scrollviews i use in the app i work on right now, so i guess its maybe related to what one has as content or how the scrollview or scroll content is positioned or sized or the dimensions of the clipping area.
-for those scrollviews where it happens it happens in the editor in editing time, too (so the items are then invisible inside the scrollview) but somehow they become visible again when i make the clipping area much larger than it would have to be.
-while running the game the scrollview content becomes invisible when stopping scrolling and visible again during scrolling.
I know the issue was introduced with one of the last ngui dot upgrades since before the exact same scrollviews worked fine and i haven't made any changes to them besides upgrading ngui.
So yeah, kinda weird =) Not sure if its due to maybe now different shaders being used (if the case) or something changed about the scrollview clipping handling or something completely different, couldn't track it down further yet.

I pmed you a link to a video showing the issue in action, hope it helps.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #4 on: January 31, 2014, 01:22:57 PM »
Are you using a perspective camera or explicit render queues in there?

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #5 on: January 31, 2014, 01:53:50 PM »
No on both. One thing i noticed is that it doesn't happen when the scroll content is positioned at the very top but happens as soon as it is scrolled some to not be at the top anymore, like as if it calculates the content being out of the clipping range in wrong way.

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #6 on: February 01, 2014, 10:52:08 AM »
I just uploaded a repro project showing the issue, check your pm =)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #7 on: February 01, 2014, 12:25:17 PM »
Did, and found your issue. Your scroll content has a parent which is a very small UIWidget. The scroll view uses this widget's bounds to determine if something is within view or not.

Remove the widget, and everything works fine. Resize the widget to actually envelop the content, and it also works fine.

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #8 on: February 01, 2014, 12:50:36 PM »
Thanks for looking into it =)
I see, yeah, removing that widget component for the container gameobject in my scrollview gets rid of the issue of my stuff becoming invisible when not scrolling.
But the thing is: i sorta have such dummy widget components on container gameobjects in a few places in the app, mostly for reasons like being able to anchor/position containers easily and/or to depth sort the container or for other reasons.
The reason why i set the height to two for the widget on the container gameobject was that i didn't want the content area calculations of the scrollview be affected by that container widget (and instead it should take the content dimensions of the content in the container).
In previous ngui version (till until around 3 dot updates before) that worked perfectly fine and the scrollview would take the dimensions of the content for its clipping calculations (as it should). The way it works now where it just takes the dimensions of the widget of my scrollcontent container gameobject instead of the dimensions of the content itself in total for its clipping calculations is way less useful to me.
Its also more cumbersome if now for all container widgets i have to set the dimensions of the widget manually to the dimensions of the nested content (especially since for most of those containers i populate the content in them at runtime and it changes in height so that's cumbersome to always update the dimensions of the widget on the container gameobject to match the content else the scrollview clips the content away)

Anyway, for now i'll address it by altering the dimensions of the widget of the container gameobject but would be cool if you could reconsider that setup change for a future update.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #9 on: February 01, 2014, 01:03:02 PM »
To be honest, the first thing that comes to mind is "optimization" -- if there is only one child, and it's a widget, it makes sense to just use its dimensions rather than call the expensive GetComponentsInChildren<UIWidget>().

However taking a brief glance at the code I don't see where I'm doing that. So wherever I made the change... I can't find it anymore.  :o

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #10 on: February 01, 2014, 01:08:06 PM »
=)
Yeah, in general i agree, if there's only one child for the scrollview and that child has no children, then it would be sensible.
But yeah, you should check if that one child of the scrollview has no children, else you should consider the total dimensions of the children of the child.

Dennis_N

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: UIPanel disappears after scrolling
« Reply #11 on: February 06, 2014, 05:58:54 PM »
I took your advice and checked the grid object that held the content. It had indeed a widget script attached, with a default 100x100 size to it. I adjusted the size and the scroll content stopped disappearing.
Thanks!