Author Topic: Drag Drop Example 1st item can't be interacted with - NGUI 3.0.5  (Read 5576 times)

biggestgeek

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Drag Drop Example 1st item can't be interacted with - NGUI 3.0.5
« on: November 24, 2013, 08:32:49 AM »
I was going through the Drag and Drop Example and realized that the first item on the list can't be dragged out of the window. I have experienced similar issues where having buttons on the scene or having scroll bars would render the the drag and drop items inactive/ not being able to be interacted with. Is there a bug in the system or am I doing something wrong.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Drop Example 1st item can't be interacted with - NGUI 3.0.5
« Reply #1 on: November 24, 2013, 04:46:23 PM »
How odd. I will investigate and fix, thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Drop Example 1st item can't be interacted with - NGUI 3.0.5
« Reply #2 on: November 24, 2013, 05:20:15 PM »
Alright, so the issue was a simple one and was due to the legacy way of setting things up. The box colliders in that example are present on game objects rather than on widgets, which means that depth calculation for game objects takes the lowest depth of the widget within. This resulted in two box colliders having the same depth.

I've fixed it by moving the box collider onto the background object instead, where it should have been to begin with.

biggestgeek

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Drag Drop Example 1st item can't be interacted with - NGUI 3.0.5
« Reply #3 on: November 24, 2013, 11:08:23 PM »
Thanks! That fixes a number of issues. I set up my scene like the example with the fixes you described and have come up with an issue. When I double click on a Drag Drop Item, its depth value jumps to -94 and renders it unclickable. Would that be an issue with the way I set it up or something else. Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Drop Example 1st item can't be interacted with - NGUI 3.0.5
« Reply #4 on: November 25, 2013, 12:37:08 AM »
-94? Not sure where that would come from. I suggest you use the "Normalize" option from the NGUI menu to bring your depths in order to start with.

biggestgeek

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Drag Drop Example 1st item can't be interacted with - NGUI 3.0.5
« Reply #5 on: November 25, 2013, 01:47:34 AM »
Hey, Just a heads up found something in the Drag Drop Item code that caused it.

The code:
  1. // Inflate the depth so that the dragged item appears in front of everything else
  2.                                 //UIWidget[] widgets = GetComponentsInChildren<UIWidget>();
  3.                                 //for (int i = 0; i < widgets.Length; ++i) widgets[i].depth = widgets[i].depth + 100;

Does not inflate the depth but the other line:
  1. // Restore the depth
  2.                 UIWidget[] widgets = GetComponentsInChildren<UIWidget>();
  3.                 //for (int i = 0; i < widgets.Length; ++i) widgets[i].depth = widgets[i].depth - 100;

Reduces the depth hence making the depth -94 as my original depth was 6. Commented both out and it worked fine. Thanks!