Author Topic: DragAndDrop: Dragging position wrong  (Read 3460 times)

EToreo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 88
    • View Profile
DragAndDrop: Dragging position wrong
« on: January 19, 2013, 04:40:20 PM »
I am trying to set up a drag and drop form and have followed the example as best I could.  For the most part, it's working.  But when I drag the item (a Sprite) it "lags" the mouse position (like it's scaled).  I have checked the different panels that are involved and everything has a scale of <1,1,1>.  The closer the mouse is to the origin point of the drag-able item, the closer the item is under the mouse - but the further away the mouse drags from the origin, the further away the mouse gets from the dragging item.

Any ideas why the object being dragged isn't under the mouse?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: DragAndDrop: Dragging position wrong
« Reply #1 on: January 19, 2013, 05:15:38 PM »
What version of NGUI? What is your UIDraggablePanel.scale at?

EToreo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 88
    • View Profile
Re: DragAndDrop: Dragging position wrong
« Reply #2 on: January 19, 2013, 05:32:51 PM »
2.2.7c

I have multiple drag-able panels on the top-level panel.  All are set to <0,1,0> (so you can only drag in the Y).  That's an interesting question, because the drag-able panels don't have anything to do with the dragging as far as I can tell.  Thanks for the help, what's the next step?

EToreo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 88
    • View Profile
Re: DragAndDrop: Dragging position wrong
« Reply #3 on: January 20, 2013, 03:20:48 PM »
This is very confusing.  I have noticed some other inconsistencies.  When I specify a clipping panel I have to give exaggerated values for the clipping size x and y to make it behave correctly in game mode - but it looks wrong in the inspector view.

I don't know if this is related at all to the dragging problem, but it appears to be "off" by about the same scale (around 1.75).

I have checked EVERYTHING in the tree to make sure the scales are all set to <1, 1, 1>.  The only exception is the UIRoot.  It has a very small scale <0.001953, 0.001953, 0.001953>, but I suspect that's normal.

---
P.S.  I am willing to send you my scene, if it comes to that.
« Last Edit: January 20, 2013, 03:23:28 PM by EToreo »

EToreo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 88
    • View Profile
Re: DragAndDrop: Dragging position wrong
« Reply #4 on: January 20, 2013, 04:43:32 PM »
Checking "Automatic" in the GUI Root changes things a bit...

The difference in the clipping panes between Inspection mode and Game mode disappears.  Clipping looks the same in both modes (and is correct).

The dragging "lag" factor seems to be less - but is still there.

EToreo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 88
    • View Profile
Re: DragAndDrop: Dragging position wrong
« Reply #5 on: January 20, 2013, 04:50:15 PM »
I finally got smart and figured out that the pixel size adjustment was probably the common factor between the "automatic" modes.

Modifying this line in DragDropItem.cs:
  1. mTrans.localPosition += (Vector3)delta;

To read as such:
  1. mTrans.localPosition += (Vector3)delta * GuiRootManagerScript.SceneInstance.GetComponent<UIRoot>().pixelSizeAdjustment;

Worked for me.  That won't work for everyone, but the idea is that the UIRoot's pixelSizeAdjustment is used.

vrgz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: DragAndDrop: Dragging position wrong
« Reply #6 on: March 09, 2013, 09:57:50 PM »
I had same problem.

and
mTrans.localPosition += (Vector3)delta * UIRootobject.GetComponent<UIRoot>().pixelSizeAdjustment;

works for me.

vrgz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: DragAndDrop: Dragging position wrong
« Reply #7 on: March 09, 2013, 09:58:55 PM »
by the way I use 2.3.4 the last version