I’m hoping to create a GUI where the user can drag items from one part of the GUI and place them in a designated position within another part of the GUI. For example, think of a roleplaying game where you might be moving items from a player’s backpack onto slots superimposed on a picture of the character for headwear, bodywear, etc.
Nobody? Ok, let me try and split this up and see if anybody can suggest anything for the component parts.
Can I detect when the mouse has been depressed over a GUI element? I can’t use the return value from GUI,Button because that only triggers on the mouse-up event.
Can I track the current position of the mouse in screen place, and render something in the GUI at that point?
Can I detect when the mouse has been released, and determine which GUI element is underneath the mouse pointer?
Nope, didn’t even know there was a Wiki until now! So thanks for that. This script looks interesting. but I’m guessing that can’t be used with a normal OnGUI() style GUI, right? I mean, I don’t even know how to get access to any GameObjects that might exist as part of the OnGUI call.
Ok, that’s a start, thanks! But is there a “PointInWhichBox” equivalent for existing GUI elements? Or is that impossible due to the nature of the immediate-mode rendering? I need to be able to detect what I’ve dropped the object on, and ideally the drop target will change dynamically with vertical and horizontal control groups so I can’t use a mathematical formula alone as the example does.