Problem with GUI.Button

Hi all, I’m starting with Unity and since yesteraday I have a problem that I can’t resolve.
I’m using GUI.Button to create 7 buttons, and I should be able to move this buttons with the mouse (like if this button was the piece of a puzzle).
Can somebody explain me how to do that?

Thanks!!
Ana

Do you really need these to be buttons ? I mean, a button is meant to be a clickable area on the screen. It seems what you want to do is just have 7 boxes displayed on the screen, which can be moved by the user in a certain order. If you don’t need the “click” functionality of a button, you might want to use simple planes with a 2D texture to represent your 7 states.

Try this:

    private Rect sampleButton = new Rect (100,100,80,25);
    private bool sampleButtonSelected = false;
    void OnGUI()
    {
        if (sampleButtonSelected)
        {
            sampleButton.x = Input.mousePosition.x - 40;
            sampleButton.y = Screen.height - Input.mousePosition.y - 10;
            if (GUI.Button(sampleButton, "Sample!"))
            {
                sampleButtonSelected = !sampleButtonSelected;
                //do something
            }
        }
        else
        {
            if (GUI.Button(sampleButton, "Sample!"))
            {
                sampleButtonSelected = !sampleButtonSelected;
                //do something
            }
        }
    }

This is just one button sample, but if you get the idea, you sure can reproduce it to the others…