A control that allows resizing of a parent panel by dragging a handle, maintaining aspect ratio and respecting min/max size constraints.
1 Overview
3 Methods
4 Usage
6 See also
The ResizePanel control enables users to resize a parent panel by dragging a handle component. It automatically maintains the original aspect ratio and constrains resizing within specified minimum and maximum bounds (calculated as 10% to 1000% of the original size).
The properties of the ResizePanel control are as follows:
| Property | Description |
|---|---|
| Min Size | Minimum size constraint for the panel (Vector2). Automatically set to 10% of original dimensions in Awake() |
| Max Size | Maximum size constraint for the panel (Vector2). Automatically set to 1000% of original dimensions in Awake() |
The ResizePanel control implements Unity’s IPointerDownHandler and IDragHandler interfaces but does not expose additional public methods.
| Method | Arguments | Description |
|---|---|---|
| OnPointerDown | PointerEventData | Handles pointer down events to bring panel to front and record starting position |
| OnDrag | PointerEventData | Handles drag events to resize the parent panel while maintaining aspect ratio |
To use the ResizePanel control:
Example code for manual configuration:
var resizePanel = resizeHandle.GetComponent<ResizePanel>();
resizePanel.minSize = new Vector2(100, 100);
resizePanel.maxSize = new Vector2(1000, 1000);
Video demonstration to be added
Credits: .entity