Author Topic: Drag Drop item issue  (Read 2022 times)

Tomleung

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Drag Drop item issue
« on: May 22, 2014, 02:08:18 AM »
Is it possible to restrict the user to drag some items on certain surface only?

For example, if I put one dragdrop surface on the ground and another one on the ceiling , I want to let the user only can put some chairs on the ground surface but only can put some lights on the ceiling surface. Is it possible? If possible, how to implement it?

Thx.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Drop item issue
« Reply #1 on: May 22, 2014, 03:45:16 PM »
Create your own custom DragDropItem like I did with ExampleDragDropItem. You can do what you want inside, including adding logic that differentiates between different surfaces.

Tomleung

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: Drag Drop item issue
« Reply #2 on: June 18, 2014, 11:04:53 AM »
Create your own custom DragDropItem like I did with ExampleDragDropItem. You can do what you want inside, including adding logic that differentiates between different surfaces.

Did you mean that I need to create another DragDropitem and ExampleDragDropItem scripts like DragDropitem2 and ExampleDragDropItem2, and use these two scripts to implement in some items on DragDrop so it can separate two cases?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Drop item issue
« Reply #3 on: June 18, 2014, 04:34:30 PM »
ExampleDragDropItem derives from DragDropItem script, implementing custom behaviour. So you would do the same -- derive from DragDropItem, implement custom behaviour.

Tomleung

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: Drag Drop item issue
« Reply #4 on: June 19, 2014, 02:55:22 AM »
Thanks. I would try it.

One more question I would like to ask is that is it possible to drag and drop items on grid , by using your DragDropSystem ?

For example, if I would like to drag and drop items on the grids of the surface only, is it possible ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag Drop item issue
« Reply #5 on: June 19, 2014, 06:11:07 PM »
How is the grid defined? Remember, drag & drop works with colliders. So if you have an inventory that's, for example a grid of 8x8 cells, each cell would ideally have its own collider. This way you will know exactly over which collider you're dropping the dragged object.