Author Topic: [SOLVED] Dragging doesn't work when there are children  (Read 5249 times)

BrightBit

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 21
    • View Profile
[SOLVED] Dragging doesn't work when there are children
« 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.
« Last Edit: March 02, 2014, 02:00:12 AM by BrightBit »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dragging doesn't work when there are children
« Reply #1 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.

BrightBit

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 21
    • View Profile
Re: Dragging doesn't work when there are children
« Reply #2 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dragging doesn't work when there are children
« Reply #3 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?

BrightBit

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 21
    • View Profile
Re: Dragging doesn't work when there are children
« Reply #4 on: March 01, 2014, 02:47:43 AM »
There are just 2 colliders in the gui. The items don't have collider components:


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dragging doesn't work when there are children
« Reply #5 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.

BrightBit

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 21
    • View Profile
Re: Dragging doesn't work when there are children
« Reply #6 on: March 02, 2014, 01:59:37 AM »
Okay, you were right. That was the problem. Thank you. :)