OnMouse[...] Event

Hi all,
I have a problem, I have a script attached to multiple GameObject with a box collider in a canvas.
In this script I have 4 Mouse Event for the same GameObject :
OnMouseDown => to create the same GameObject, but i can move it on the scene;
OnMouseDrag => to move the GameObject i’ve created with OnMouseDown;
OnMouseUp => to check if the GameObject isn’t on my canvas, if it is, I destroy it, or I restore his position/rotation in the last position before the movement;
OnMouseUpAsButton => to instantiate a window where i can rotate the GameObject as I want.

The probleme is that : OnMouseUpAsButton is called even if I move my mouse, so it create my window even if I just want to drag and drop the GameObject;

I think OnMouseUpAsButton doesn’t work perfectly in my case, need some suggestion to resolve this.
Thanks

I think you need to manually create these, not use OnMouseDown on an object or so.

Have a controller that uses Input.GetButtonDown, GetButtonUp and so on.

Then, using this, you could do a plane cast or create the object where the mouse hits a raycast or so. This will tell you where the event is.

You might also be interested in the EventSystem interfaces… if you’re using a canvas you already have the raycaster and eventsystem components/gameobjects in play…

https://docs.unity3d.com/ScriptReference/EventSystems.IBeginDragHandler.html
https://docs.unity3d.com/ScriptReference/EventSystems.IPointerUpHandler.html
etc. (should see all the interfaces in the tree on the left)

also, little known fact (and a source of some examples of implementations of the above) the UI source is here: https://bitbucket.org/Unity-Technologies/ui/src