How can I make draggable GUI Buttons?

How could I possibly make a gui button that is draggable? I haven’t really been able to understand this concept that well.

Looking at your history it seems you have asked mostly about bits related to creating a drag/drop Inventory which delves into some intermediate stuff that’s not easy to just pick-up without some experience or vid/tut guidance.

There’s no out-of-the-box draggable GUI.Button since it takes a Rect(); with scripting you could redefine the Rect based on mouseInput or such, but it’s not real simple.

Instead of a true GUI.Button, you could…

Search UA/Google on ‘drag drop GUI’ came up with other alternatives as well.

This is something that can be done very easily actually, whether you are using a 3D object or 2D object.

All you do is attach a script to the game object you want to make “click and draggable”. In this script, make it so when the mouse position intersects the objects position (most likely will need a collider on the object to do this), that the object with highlight or something or the mouse changes. Then on left click, you can put the object in “edit” mode. While it’s in “edit” mode, the objects transform.position will be set to the transforms of mouse. When the user reclicks or lets go of the left mouse, then set the “edit” mode to false. Using a single object script would be great because you can re-use it across multiple objects. To avoid issues with multiple objects being clickable while one is already being dragged, you can have a master script that determines if the state of the mouse is currently dragging an object.

The only tricky part you will have is if you are trying to do this in 3D instead of 2D. In 3D, you will most likely have to use “Camera.ScreenWorldToPoint”. Unity - Scripting API: Camera.ScreenToWorldPoint

That function will allow you to figure out the relation between the 2D position of the mouse and the 3D world. It’s very easy to use. This is not very hard what you are trying to accomplish and unfortunately, like the others said, there isn’t really a generic/default Unity script that has this capability. I hope that helps.