Hello everybody!
Can’t implement drag and drop to grid. I know how to do drag and drop without grid, I also know how to drag 1 cell item. Dragging objects on a grid, the size of which, for example, 2 cells, leads me into confusion. I don’t understand how to make a drop for several cells at once. I would be grateful for your help! An example of what I want to achieve in a GIF.
Definitely start with some drag and drop inventory tutorial videos on Youtube for this. There are plenty of them with just 1x1 simple squares, but there are also more complex ones that have multi-cell objects.
Honestly, I could not find a single video that tells how to drag and drop a multicellular object. I can implement drag and drop for a single-celled object. Can I form the request on youtube incorrectly?
Or maybe you’ve seen similar topics on the forum that might help me?
I know I’ve seen at least one but I have no idea where or when.
The idea is simple enough to implement:
With 1x1 cells, at some point during dragging you make a decision: “Can I drag this here?”
Extract all the information going into that question into an API that says “Given a 1x1 shape here, can I fit?”
Once you have done that, then add an extra argument saying the dimensions. “Given a 1x3 shape here, can I fit?”
Iterate.
Well, I’ll try to build on what you wrote. Thanks for the tip, I didn’t think I would get feedback so quickly. In Unity community we trust)
You’re welcome! Just work methodically and break it apart, so that you really are saying “Hey can I put this 1x1 here?” with a bunch of arguments. When you code like that, it can be easier to extend functionality to say “Hey can you fit this SHAPE here?”