Drag and drop texture

Hi, im working on a script to grab a texture using mouse and move it throught the screen. I want to move different textures to order it.

I have:

void OnGUI() {

			rect= new Rect(rectx,recty,100,100);

			if(Event.current.type == EventType.MouseDrag)

				Vector2 tempDelta = Event.current.delta;
				rectx=tempDelta.x +rectx;
				recty=tempDelta.y +recty;
				rect = new Rect(rectx,recty,100,100);
				//transform.Translate (tempDelta*-0.05f);


With this i can move the texture but always without moving out of the texture or it stops. How can i fix it?


you can have a variable called "drag" and then make it true when you click on a texture and then move the texture to mouse position till a mouse up event occures.