Resize GUI Controls with Mouse

We want to let the user the posibility to resize GUI.Windows but i guess is not so easy…
So, Does any body try to resize GUI controls wtih mouse move and click events?
Regards…

Actually quite an interesting question. My guess would be to create a “hotspot”, say for the lower right corner of the control you want to resize, and then use OnMouseDown() to grab that corner. I would create the hotspot as some sort of GUI element that can receive mouse events. Then you can use the difference between the top left corner and the mouse position to define the size of the control. Then use OnMouseUp() to “let go” of the control’s corner. Make sure to synchronise the location of your hotspot and the corner of your control. You also may want to offset the location of one or the other for visual clarity.

Don’t have any code at the moment; I’d have to tinker with it.

Another approach (although clunky) might be to just add tiny buttons around your control so that the user can click a button to change the size.

If you don’t have time to mess with it, you might want to see if the built-in controls can already do what you want (though I imagine you’ve already done that).

Hope this helps!

I ran into a similar situation recently,
here is my solution to this issue:

private var WindowRect = Rect (150,150,250,100);

function OnGUI() {
	
	WindowRect = GUILayout.Window (3, WindowRect, MakeWindow, "test");	

}
function MakeWindow (id : int) {
	// resizing button
	resize_enabled = GUI.Toggle(Rect (WindowRect.width - closeButtonStyle.normal.background.width -4,
			     WindowRect.height - closeButtonStyle.normal.background.height -4,
			     closeButtonStyle.normal.background.width,
			     closeButtonStyle.normal.background.height), resize_enabled, "", "close_button");
	
	if (resize_enabled) {
		WindowRect.width = Input.mousePosition.x - WindowRect.x + 8;
		WindowRect.height = (Input.mousePosition.y * -1) + Screen.height -  WindowRect.y + 8; 		
	}
        
}

You’ll probably have your own custom style instead of “closeButtonStyle”.

http://forum.unity3d.com/threads/235036-Resizing-a-GUI-Window-solution-thought-I-d-share

This is the solution I use. Link to make it easier for fellow newbs (such as myself) to find easier in the future.