Author Topic: Dropping inventory items outside of slots  (Read 3384 times)

booleanBoy

  • Guest
Dropping inventory items outside of slots
« on: June 12, 2012, 10:36:05 AM »
Hi,

I've been pulling apart the character inventory tutorial scene and am beginning to get my own inventory working OK. One thing I can't seem to figure out though is how to return the item to the slot it was drag from when it's not dropped on another slot/valid drop site.

Any tips would be greatly appreciated,


Rob

PhilipC

  • Guest
Re: Dropping inventory items outside of slots
« Reply #1 on: June 12, 2012, 12:22:53 PM »
There is a function that gets called when the item is dropped (OnDrop). If in that method you check to see if your over a valid slot if not reset its position to the slot it started from (you would have to store its original slot)

booleanBoy

  • Guest
Re: Dropping inventory items outside of slots
« Reply #2 on: June 13, 2012, 05:19:50 AM »
Thanks for the reply.

It's purely the event firing that I need help with, I can manage the other stuff.

It looks like OnDrop only gets called if the drop occurs over something with a collider and the OnDrop is called on that object, where as I need to return the item when it's dropped anywhere else. An invisible collider might work but that seems counter intuitive and may cause problems down the road...

Im implementing this on iOS so as it stands, if the finger stops dragging the result will be the 'cursor' drag icon sitting at the last known finger position. This is obviously not the behaviour I want.

Is there something within the events system that catches when there's no OnDrop functions to call?

Thanks

PhilipC

  • Guest
Re: Dropping inventory items outside of slots
« Reply #3 on: June 13, 2012, 08:09:20 AM »
What you looked at the DragDropItem script that came as an example free with NGUI? What it does it watches for a OnPress(false) and calls a Drop function manually instead of OnDrop.