A control that enables dragging a rescaled panel to reposition it within a canvas, compensating for the panel’s local scale during movement.
1 Overview
3 Methods
4 Usage
6 See also
The RescaleDragPanel control allows users to drag and reposition a panel that may have been rescaled. It automatically accounts for the parent’s local scale when calculating drag offsets, ensuring accurate positioning. The panel is constrained to remain within the canvas boundaries during dragging.
The RescaleDragPanel control has no serialized properties exposed in the inspector. All functionality is handled internally through automatic canvas and parent detection.
The RescaleDragPanel 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 calculate initial pointer offset |
| OnDrag | PointerEventData | Handles drag events to reposition the panel, accounting for local scale and clamping to canvas bounds |
| ClampToWindow | PointerEventData | Internal method that clamps the pointer position to canvas boundaries |
To use the RescaleDragPanel control:
This control works best when combined with RescalePanel to provide both rescaling and repositioning functionality.
Example setup:
// Typically no code configuration needed - add component and it works automatically
// The control self-configures in Awake() by detecting the parent Canvas and RectTransform
Video demonstration to be added
Credits: .entity