Can I get a GUI gameobject by mouse down and mouse up ?

Hello
I try to get gameobject by mouse down(First Object) and mouse up(Second Object) for a hour but I don’t see a good solution for me.
I want to create drag and drop able slot (It have 4 type 1.Item 2.Skill 3.Equipment 4.Store) I need my script when Mouse Down get first object Mouse Up get second object (For example First Object is Store Second object is empty Item slot) I want to compare something like tag(item from store have various tag) but I don’t know how to get Item.

I try this attached this script to UI but nothing happen.
private void OnMouseOver ()
{
Debug.Log(“Over”);
}

and I try event trigger and use method like this but this method require me to assign each object (about 100-150 object ) and I feel this method have bad performance can someone tell me about fact.
public void StartDrag (GameObject Tester)
{
FirstObject=Tester;
}
I try to find about raycast but I don’t see good solution too.

If you want to know any information please let me know.
Thank you for reading

If these are unity gui, I’d look at the interfaces unity has for these.
such as
https://docs.unity3d.com/ScriptReference/EventSystems.IDragHandler.html
https://docs.unity3d.com/ScriptReference/EventSystems.IPointerEnterHandler.html

There are others, but you should be able to find them from those links.

1 Like