Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Alraune on July 02, 2015, 03:04:44 PM

Title: Drag without mouse offset
Post by: Alraune on July 02, 2015, 03:04:44 PM
Hello, everyone. I've searched on forum but did not find an answer to my question, on drag & drop example when i pick an object he doesn't snap the center to my mouse cursor, it creates an offset that allow me to carry an item no matter where i click. But i want to snap the center of the item with my mouse cursor, how to achieve this?
Title: Re: Drag without mouse offset
Post by: ArenMook on July 02, 2015, 09:03:46 PM
Actual movement happens in UIDragDropItem.OnDragDropMove by adjusting the localPosition (which is called from UIDragDropItem.OnDrag). If you want it to snap, you will want to look at UIDragDropItem.OnDragStart, overwrite it in your custom Drag & Drop class derived from this one, and set the transform's localPosition to what you need it to be.
Title: Re: Drag without mouse offset
Post by: Alraune on July 03, 2015, 01:11:10 PM
Actual movement happens in UIDragDropItem.OnDragDropMove by adjusting the localPosition (which is called from UIDragDropItem.OnDrag). If you want it to snap, you will want to look at UIDragDropItem.OnDragStart, overwrite it in your custom Drag & Drop class derived from this one, and set the transform's localPosition to what you need it to be.

Thank you! i was able to code my drag to do the behaviour i was searching.