Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: urban on April 19, 2014, 08:26:24 AM

Title: Drag and Drop problem
Post by: urban on April 19, 2014, 08:26:24 AM
HI,

I have created a inventory system using NGUI but i have a problem while dragging the item, the sprite doesnt not keep to the center of the mouse curser.

Here is a link to my script

http://pastebin.com/K8CTaUTZ

the code for the inventory works fine.

I do not use the uidragroot as that causes more problems
Here is a screen shot of the problem

https://www.evernote.com/shard/s225/sh/b1ef46de-559e-4041-afed-71bcb30dee3d/250298cf176802d8a1501b71019cb9e2

Please could you help.



Title: Re: Drag and Drop problem
Post by: ArenMook on April 19, 2014, 11:10:51 PM
You are setting "mTrans.localPosition = Input.mousePosition;" -- This is wrong. Input.mousePosition is in screen coordinates. Transform's localPosition is in local coordinates -- relative to the parent. You need to convert screen to world, then convert world to local using standard math functions (camera.ScreenToWorldPoint, transform.parent.InverseTransformPoint)
Title: Re: Drag and Drop problem
Post by: urban on April 20, 2014, 04:42:39 AM
Thanks very much this solved the issue