Author Topic: Deactivated objects drawing while scrolling  (Read 4912 times)

Ayrik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Deactivated objects drawing while scrolling
« on: November 19, 2012, 01:02:27 PM »
I have a UIPanel with a UIDraggablePanel component. I have manually placed all objects to scroll in the scene, and all scrolling and clipping is working perfectly. However, when I started deactivating things dynamically in OnEnable in each object, things get strange. Some of the objects that are disabled, still render in the clipping rect, but ONLY while dragging. Also, it is only a few objects, but these objects are the same ones each time. There are quite a lot of objects I suppose.

Let me know if you need any more info. For now I've just set their depth to be behind a background sprite when I disable them, but I'd like to avoid that in the future. I'm using Unity 3.5.6 and NGUI v2.2.3.

Oh yeah, I thought I should mention the way I'm deactivating the objects: I've tried NGUITools.SetActive, gameObject.SetActiveRecursively, and also sprite.enabled. All these share the same results.
« Last Edit: November 19, 2012, 01:08:52 PM by Ayrik »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Deactivated objects drawing while scrolling
« Reply #1 on: November 19, 2012, 05:09:58 PM »
When dragging, all objects in the clip view are purposely enabled and culling checks are not performed. Once the movement stops, culling occurs and widgets that aren't visible get disabled.

You need to make sure that everything inside your draggable panel uses a proper shader (Unlit/Transparent Colored). Using any other shader means you won't get clipping unless you manually add it yourself.

Ayrik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Deactivated objects drawing while scrolling
« Reply #2 on: November 19, 2012, 09:09:24 PM »
As I mentioned, the clipping works perfectly. But, what you are saying is there is no way to have deactivated sprites within a draggable panel because it turns them on automatically while dragging?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Deactivated objects drawing while scrolling
« Reply #3 on: November 20, 2012, 03:39:43 AM »
"When dragging, all objects in the clip view are purposely enabled and culling checks are not performed."

Isn't this bad? I'm almost certain I'll have to mess around with it to disable/reuse containers to be able to get good enough performance in long lists (think 100+ facebook friends in a list, with picture etc). In a "raw" scroll list it runs terrible even on a iphone 4s right now. :/

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Deactivated objects drawing while scrolling
« Reply #4 on: November 20, 2012, 10:07:42 AM »
Yup, that's an issue I reported here : http://www.tasharen.com/forum/index.php?topic=1360.msg6971#msg6971 (but the rest is via email with Mike and PhilipC)

And as a result of this issue, I only display the facebook friend list with 100 rows, and a next/previous button at the bottom... :(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Deactivated objects drawing while scrolling
« Reply #5 on: November 20, 2012, 03:40:41 PM »
@Nicki and nah0y: Doing clipping checks on all widgets every single update and then updating the draw buffer is much worse for performance than displaying everything and not touching the buffer.

@Ayrik: Unity 4 supports hierarchical activation. You can have a disabled child of a parent and not have it get activated when the parent gets activated.

Ayrik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Deactivated objects drawing while scrolling
« Reply #6 on: November 26, 2012, 06:08:43 PM »
Yes, but these objects are already deactivated. Anyway, my solution was to move the objects behind something else, or way far off the screen. It's horrible to have to do that, but it worked. This is not an issue with culling or clipping. Some deactivated objects reappear while dragging, then disappear after stopping again. It wouldn't be so weird except that only a few objects do this, and they are always the same ones, with no obvious differences that I can see between them. It seems like a bug to me.

Sorry for the delayed response, but after the workaround I just forgot about this issue until today.