A control that rescales a parent panel by dragging a handle, adjusting the local scale while keeping the UI element size consistent.
1 Overview
3 Methods
4 Usage
6 See also
The RescalePanel control allows users to rescale a parent panel by dragging a handle. Unlike ResizePanel, this control modifies the parent’s local scale rather than its size delta, and automatically adjusts the handle’s size delta to maintain visual consistency during scaling.
The properties of the RescalePanel control are as follows:
| Property | Description |
|---|---|
| Min Size | Minimum scale constraint for the panel (Vector2). Defines the minimum local scale values for X and Y axes |
| Max Size | Maximum scale constraint for the panel (Vector2). Defines the maximum local scale values for X and Y axes |
The RescalePanel 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 rescale the parent panel by adjusting local scale and compensating handle size |
To use the RescalePanel control:
Example code for setting scale constraints:
var rescalePanel = rescaleHandle.GetComponent<RescalePanel>();
rescalePanel.minSize = new Vector2(0.5f, 0.5f); // Minimum 50% scale
rescalePanel.maxSize = new Vector2(3.0f, 3.0f); // Maximum 300% scale
Video demonstration to be added
Credits: .entity