Author Topic: 2 Grids + Drag and Drop Bug?  (Read 4923 times)

crisv

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
2 Grids + Drag and Drop Bug?
« on: October 14, 2014, 03:19:34 AM »
I am trying to move drag and drop items between two grids, with a parent drag drop container assigned to each grid's parent.  The drag and dropping works perfectly but I have noticed that the placement of the objects when moving between the two different grids is incorrect.  It seems to me as though some of the settings from the previous grid is carried over onto the dropped object.

For example: Grid1 has a smaller spacing between items.  I drag an item from Grid1 to Grid2 (which has a larger spacing).  The items clump up as if they are using the spacing from Grid1.  When I fiddle around with it it seems to eventually fix itself, but I can't get it to fix on the first drag and drop, even if I try to manually 'Execute' on the grid.

Another reason why I thought this could be an issue related to property carry-over from the previous grid is I noticed in the Drag and Drop example (Example 11) if you drag an item onto the other grid and then immediately try to scroll/drag it, the previous grid is the one that is moving.  After a second or two this behaviour fixes itself.

I'm not sure if those are related issues or not but it seems like it could be.  Does anyone have any ideas what else I may be doing incorrectly?  I'm admittedly quite new to NGUI


By the way another problem I seem to be having is the offset at which I start dragging from on an object seems to change the further I drag it away from where I began dragging.  For example if I drag something holding it from the center of the object/collider, the further I get the further off-center my mouse looks from the center of the object.  This is a minor problem for small drags but I can see it being an issue in some circumstances.
« Last Edit: October 14, 2014, 03:38:52 AM by crisv »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 2 Grids + Drag and Drop Bug?
« Reply #1 on: October 14, 2014, 02:57:34 PM »
Make sure you update to the latest NGUI, and the last issue should go away.

The first issue I'm not entirely clear on. Items clump up? Have you tried changing the cell size on one of the grids in the drag & drop example, or is this only something that happens in your scene?

crisv

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: 2 Grids + Drag and Drop Bug?
« Reply #2 on: October 15, 2014, 02:31:37 AM »
Thanks for the swift reply.

I have made sure I'm updated to the latest version but I still am having issues with the offset on the drag n drop item.  It seems to be behaving worse on certain drag drop items I have set up than others.. not sure if maybe I have done something incorrectly with the colliders I have on them perhaps?

I can't recreate the same clumping problem in the example scene but I have noticed one difference with the implementation in that scene VS my scene is that I am not using any scrollviews - not sure if that matters.  I just want a grid of 10 items (like an inventory 2x5) and a horizontal row (like a skill hotkey row 1x3) and the user can drag and drop between those two but for some reason sometimes the items in the latter don't snap to the correct grid spacing.  I'll try to look deeper into each implementation.

crisv

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: 2 Grids + Drag and Drop Bug?
« Reply #3 on: October 15, 2014, 02:48:34 AM »
I did a bit more testing.  It seems like it messes up (clumps up) when I drop on object on top of another in the grid, for some reason.  Then if I drag and drop in 'empty space' on the grid it will correct itself.  This is the behaviour when dropping in the same grid.  It also messes up if I drag and drop from a different grid onto another grid with different cell spacing.

I will try to investigate some more.  If noone else has experienced this then maybe it's a setup problem in my scene.
« Last Edit: October 15, 2014, 02:57:57 AM by crisv »

crisv

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: 2 Grids + Drag and Drop Bug?
« Reply #4 on: October 16, 2014, 04:34:21 AM »
thought i'd post a follow-up.

the drag and drop offset was because of the scale on the drag drop pivot object not being 1.  i'm not sure where it got changed slightly but it did.  works like a charm now.

i seem to have gotten rid of the grid placement issue but i have to turn off the smooth tweening.  when i enable that again i get a lot of weird behaviour with the grid placement.  sometimes the spacing is off and sometimes an object will be placed on top of another and leave an empty space before it etc.  i'm not sure what the problem is there yet but for now i'm going to just not have smooth tweening.