How can I make an Editor Window Box Draggable?

I just started working on an editor window that is similar to Shader Graph and I want to make boxes draggable like nodes. How can I do this?

Yes, the usual way is to simply use GUI.DragWindow inside your GUI.Window / GUILayout.Window callback. When you don’t specify a rect the whole window background will be draggable. If you specify a rect, that rect is relative to the windows top left corner. A common usecase for usual window styles is to use something like

GUI.DrawWindow(new Rect(0,0,10000,15));

which will make the top 15 pixels of the window draggable which corresponds to the title bar of the window.

Of course you can implement your own drag logic if you want.

Keep in mind that the IMGUI system is an immediate system and things are executed in order. That means things that appear first in OnGUI / inside the window callback are processed first. In most cases you want to call the GUI.DragWindow method at the end of the callback so it doesn’t eat all input events but only those not handled by other controls like buttons, …

Hi @VoidPhoenix96 , if this is similar to what you need:

Then you can check out my example here and see how I did it.
https://github.com/AbreuRodrigo/visual-canvas-editor

Cheers