Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: BrightBit on February 26, 2014, 10:21:27 AM

Title: [SOLVED] Dragging doesn't work when there are children
Post by: BrightBit on February 26, 2014, 10:21:27 AM
Hello again,

I've got a GameObject "Backpack" with two children "Label" (with UILabel, UIDragObject [target is "Backpack"] and BoxCollider) and "Slots" (with a BoxCollider that is even overlapping the Collider of "Label").
My problem is that I can't drag the "Backpack" via "Label" as long as there are children in "Slots". I made a video to illustrate that:

https://www.youtube.com/watch?v=gMqMBkNBWRg

Any idea on why this happens?


Greetings
BrightBit

Note: There's an additional component attached to the GameObject "Slots" but it has no impact on this problem. I already tested that by removing this additional component.
Title: Re: Dragging doesn't work when there are children
Post by: ArenMook on February 26, 2014, 02:11:50 PM
Check to see what's interfering with events by enabling Debug on the UICamera and hovering the mouse over the non-responsive object.
Title: Re: Dragging doesn't work when there are children
Post by: BrightBit on February 28, 2014, 02:45:41 AM
Okay, I've done so but it didn't help me. Here's a video of it:

https://www.youtube.com/watch?v=tUNnAH_oAEc
Title: Re: Dragging doesn't work when there are children
Post by: ArenMook on February 28, 2014, 07:54:41 PM
It's hard to see in that video but what's the size of the collider? For whatever reason, the Raycast is hitting the item's collider. Is it that big?
Title: Re: Dragging doesn't work when there are children
Post by: BrightBit on March 01, 2014, 02:47:43 AM
There are just 2 colliders in the gui. The items don't have collider components:

(http://s7.directupload.net/images/140301/de782qcw.png)
Title: Re: Dragging doesn't work when there are children
Post by: ArenMook on March 01, 2014, 08:52:46 PM
Yeah that would be why. NGUI's raycasts go by widget depth. However if you don't actually have a widget, it uses the combined widget depth -- that of all the children.

You need to use an actual widget, not just put a collider on an empty game object.

ALT+SHIFT+W, ALT+SHIFT+C, resize this widget. This is the collider you should be using -- for both the title bar and the item container.
Title: Re: Dragging doesn't work when there are children
Post by: BrightBit on March 02, 2014, 01:59:37 AM
Okay, you were right. That was the problem. Thank you. :)