Author Topic: Drag and Drop a Sprite  (Read 1334 times)

camelord

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Drag and Drop a Sprite
« on: January 18, 2014, 06:28:59 PM »
Hi,

i have a fairly simple question, i guess:

I created a Grid (widget with UIGrid attached) and put in 4 sprites (widget with uisprite script).
I attached a uidrag drop container script to the grid and uidrag and drop item script to the sprites.

No i am able to move them around - great!

I want to drag any of the four sprites to an empty widget.
This way i want to give the user an opportunity to select a special game mode.

How do i get the dropping into a widget done?

A screenshot of my approach is attached.

What happens is, that the icon from the grid stays in the widget (i choose a ui2dsprite).

Who can i attach the dropped sprite to the 2D Sprite variable, that i will be shown correctly?
Or is my approach completly wrong and i have to do it in another way?

cheers
camelord

vallcrist

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 49
    • View Profile
Re: Drag and Drop a Sprite
« Reply #1 on: January 18, 2014, 07:01:56 PM »
I'm pretty sure there's an example that does exactly this in NGUI, it's a good starting point.

It's Example 11 - Drag & Drop

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Drag and Drop a Sprite
« Reply #2 on: January 18, 2014, 09:57:12 PM »
Indeed. And the video tutorial for NGUI 3.0.7 does this very thing at the end.

camelord

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Drag and Drop a Sprite
« Reply #3 on: January 19, 2014, 06:32:32 AM »
Oh - sorry then and thank you!