Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: dipu5683 on May 12, 2014, 04:05:57 AM
-
Hi
i am implementing the drag drop functionality for my cricket game where user can able to swap a player from playing 11 team to substitute player and vice-a-verse. I have implemented it as follow.
for playing 11
LeftContainer (uiwiget , drag drop container , drag scroll view,box collider) attached
- Left Scroll View ( uipanel , uiscrollview )
- Grid (uigrid )
On runtime i have added the player prefab (Drag Drop script , uidrag scroll viiew script attached) .
Similarly RightContainer for the substitute player .
Drag and drop is working in my project. But i am trying 2 following functionality.
1. when i select the 2nd position (XYZ) player from the LeftContainer and drag it , and drop it on to 3rd position (PQR) Right substitute player list , then it should swap , 3rd (PQR) player should appear at the 2nd postion of the LeftContainer & 2nd player should be adjusted at 3rd position of the Right Substitute player list container.
Presently it is adding it to the last of the list.
2. When i select a (xyz)object from leftcontainer , and drag it to some object (pqr) of rightcontainer , (pqr) object should give some give auto scale feature(visual feedback) to show that i am the destination object on which you can drop the object(xyz).
Can anybody help me out ?
thanks
-
Hi
I some how managed to implement the following
2. When i select a (xyz)object from leftcontainer , and drag it to some object (pqr) of rightcontainer , (pqr) object should give some give auto scale feature(visual feedback) to show that i am the destination object on which you can drop the object(xyz).
But i am still facing issue in implementing the following
1. when i select the 2nd position (XYZ) player node from the LeftContainer and drag it , and drop it on to 3rd position (PQR) node Right substitute player list , then it should swap , 3rd (PQR) player should appear at the 2nd postion of the LeftContainer & 2nd player should be adjusted at 3rd position of the Right Substitute player list container.
Presently it is adding it to the last of the list.
I want swaping should be done only between two position of the two containers.
-
And more issue i forgot to mention.
1. Moment i select an object and start dragging slowly then all other nodes of that grid or container reposition itself automatically.
I don't want it.
2. When i drag (xyz) some object from left container , and drop it on (pqr) object on right container, then xyz adjusted in right container , & pqr object adjusted in left container BUT PQR object comes from the right side of the left container ( with clipping ) which is looking not connected visually . It should come normally from right to left without clipping . It should come normally as i dragged the object out side the left panel (visible) .
i am using the following code to swap back.
// Container found -- parent this object to the container
target.transform.parent = (Container.reparentTarget != null) ?
Container.reparentTarget : Container.transform;
// Update the grid and table references
NGUITools.FindInParents<UIGrid>(target.transform.parent);
NGUITools.FindInParents<UITable>(target.transform.parent);
UIDragScrollView dSV = NGUITools.FindInParents<UIDragScrollView>(target);
if (dSV != null)
{
dSV.scrollView = NGUITools.FindInParents<UIScrollView>(target.transform);
}
// Notify the widgets that the parent has changed
NGUITools.MarkParentAsChanged(target);
Vector3 pos = target.transform.localPosition;
pos.z = 0f;
target.transform.localPosition = pos;
m_playing11Grid.sorted = false;
m_playing11Grid.Reposition();
m_playing11ScrollView.UpdateScrollbars(true);
m_substituteGrid.sorted = false;
m_substituteGrid.Reposition();
m_substituteScrollView.UpdateScrollbars(true);
-
1. If you don't want the grid to adjust the position of its children, then you need to modify the drag & drop item logic to not Reposition() the grid. Line 178 of UIDragDropItem.
2. Item comes in wherever you dropped it by default, but where it goes depends on the grid's sorting parameter.
-
Currently grid sorting parameter is NONE and sorted = false , currently i want it to place the dragged object, on the object where i am dropping it (UICamera.hoveredObject);