- Home /
C# UI list item drag onto 2d sprite in world space?
Hey all,
Is it possible to detect if a user drags a UI List item onto a 2d sprite in world space?
Working in C#
I currently have an icon at a base that shows up if there are any units at the base. At the moment you can drag the icon to another base in the 2d world space using simple 2d collisions. That moves the icon, and all units, and locks it down till x number of turns pass. Double clicking it(the unit icon) opens up a menu with a list of the unit objects at the base. UI Objects full of UI labels and an image created for each of the units at the base.
I would like for the user to be able to drag the unit from the UI list. To a different base object in world space. That way they can easily control where the units are on the map. However Dragging my UI doesn't seem to pick up when the UI element is over the base sprite with collisions.
Can this be done with simple collisions? Am I missing something in the scene setup? Or do I need to go to an event based system? Ray cast even?
I'm a bit hung up on the events arguments. The examples I've found. Haven't dealt with much detecting if a UI element is let go over a game object.
If you have any suggestions/references/examples of how you would go about this. That would be greatly appreciated. At the moment I'm working on other in game content. That will likely implement the same feature. So I'm using the tag "Base" for the 2d world locations. And "Unit_UI" for the UI element being dragged. So if object Unit_UI is dragged over any Base tagged game object and let go over it. It executes some code.
Again any and all help is appreciated.
Anyone have any advice or pointers on this? Still stuck on it.
Your answer
Follow this Question
Related Questions
prefabs inside content area not fitting entire width of content area? 0 Answers
How to create a turn based battle system? 3 Answers
My rigidbody2d is passing through the side of a collider2d but it's working on the top 0 Answers
2d image does not scale/stretch correctly 2 Answers
Any way to use multiple font styles within a single UI Text component? 1 Answer