Author Topic: [3.5.6] Culling issue? Elements are hidden  (Read 4739 times)

Eyello

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
[3.5.6] Culling issue? Elements are hidden
« on: April 11, 2014, 03:18:46 AM »
Hello, I have a strange problem.

I have a Root Object which is a Panel or a Widget (doesn't make a difference) which is selected in the image.
As you can see on the box on the right this is how it looks like in the editor and when the game starts regularly.

Then there is the box marked with blue and this is how it looks like if I use gameobject.SetActive(true) on the selected object.
When I enable it by hand (in the inspector) on untime it works always fine.

If more information is needed I will post it, but I wonder if I did something wrong or if that is a known issue.

My idea is there is something wrong with sorting or culling (does that even work with NGUI?). All the objects are there. If I disable a progress bar for instance the text on the left which is occluded by it is drawn.
As I upgraded to 3.5.6 the background is shown, so it does not have to do with any depth or Z value I belive.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [3.5.6] Culling issue? Elements are hidden
« Reply #1 on: April 11, 2014, 07:29:43 AM »
What do you mean the root object is a panel or a widget? The two are completely different components. Panel draws widgets. Widget is drawn by a parent panel. If there is both a widget and a panel on the same object, expect bad things to happen.

Also, not quite clear what you mean by culling in this case. Culling can be many things. Back face culling, occlusion culling, depth culling (more commonly known as a Z-test), etc.

Eyello

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: [3.5.6] Culling issue? Elements are hidden
« Reply #2 on: April 12, 2014, 11:24:52 AM »
What do you mean the root object is a panel or a widget? The two are completely different components. Panel draws widgets. Widget is drawn by a parent panel. If there is both a widget and a panel on the same object, expect bad things to happen.
Currently it is a panel. It was a widget before for some reason so I changed it to see if it made a difference.

Also, not quite clear what you mean by culling in this case. Culling can be many things. Back face culling, occlusion culling, depth culling (more commonly known as a Z-test), etc.
That is the problem, I have no clue what it is. It just is the case that the widgets like Label, Progressbar and so on are not drawn in some cases.
On the image in the blue box there is a green progress bar and a text on the left "Happy:" which is not visible (no wireframe of the text mesh and so but active in the inspector). If I deactivate the prograss bar object (one of your controll prefabs) it gets visible.
Also the frames of two of the progress bars seems to be hidden by the "overlay" object.
What is drawn and what not is different by each start. Settings like depth, Z-value makes no difference at all.

Pretty important, this only occurs when I do gameobject.SetActive(true) of the selected parent object. When I activate it in the inspector during playmode by hand it does look fine.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [3.5.6] Culling issue? Elements are hidden
« Reply #3 on: April 13, 2014, 12:44:58 AM »
There are only two other reasons why things wouldn't be visible.

1. Panel is clipped and you scaled it non-uniformly. Bad things may happen.
2. The widget was re-parented at some point at run-time and you didn't inform it by using NGUITools.MarkParentAsChanged.

Eyello

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: [3.5.6] Culling issue? Elements are hidden
« Reply #4 on: April 13, 2014, 04:28:27 PM »
There are only two other reasons why things wouldn't be visible.

1. Panel is clipped and you scaled it non-uniformly. Bad things may happen.
2. The widget was re-parented at some point at run-time and you didn't inform it by using NGUITools.MarkParentAsChanged.

Nothing of those is true here.
I solved the issue by disabling/enabling the panel instead of the gameobject. It makes no difference for me at the moment.

Prodigga

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 17
    • View Profile
Re: [3.5.6] Culling issue? Elements are hidden
« Reply #5 on: February 04, 2015, 01:26:49 AM »
I have this issue aswell. All my elements are uniformly scaled and I am using NGUITools.MarkParentAsChanged, but some of my elements are still getting culled. It happens to me when I use a Tweener to tween the position of a panel from somewhere offscreen to onscreen.

What I do is I tween the panel off screen, delete its contents, populate it with new content (using NGUITools.AddChild), and finally tween the panel back on screen. I keep having UIWidget that get culled - invisible in the scene view/game view, generate no mesh that I can see in the wire-frame view, completely culled. If I disable that UIWidget in the inspector and reenable it, it renders correctly.

StabbAmonte

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 7
    • View Profile
Re: [3.5.6] Culling issue? Elements are hidden
« Reply #6 on: February 04, 2015, 01:35:19 AM »
I have experienced a similar issue that was fixed by calling this and passing in the parent game object after adding all of my child objects.

        NGUITools.ImmediatelyCreateDrawCalls(myObject.gameObject);

Prodigga

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 17
    • View Profile
Re: [3.5.6] Culling issue? Elements are hidden
« Reply #7 on: February 05, 2015, 07:00:28 PM »
Didn't work for me. Whatever NGUI seems to be doing 'under the hood' that is causing my elements to be culled (and never reactivated) seems to just happen again when I run the function.

It's like NGUI doesn't expect my elements to come back on screen again - NGUI doesnt 'realize' the elements are moving. My Tweener tweens the position of the parent element and moves it from being completely off-screen to completely on-screen. It is initially spawned off-screen, so NGUI does whatever culling it does to get rid of those elements (as they are off screen) but it doesn't think to re-run that culling process when the elements are tweened back on to screen. Everything remains invisible.

When the tween is complete and the elements are completely on-screen, I can call "ImmediatelyCreateDrawCalls" as you've suggested and everything becomes visible again! But this doesn't help me because I need to see the elements tween on screen haha.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [3.5.6] Culling issue? Elements are hidden
« Reply #8 on: February 06, 2015, 09:33:21 PM »
NGUI keeps an eye on widgets whos transform changes. What is it you're moving, widgets or the panel? Also what version of NGUI are you using?