RectTransformAdjuster
Coding Style wiki
RectTransformAdjuster is a RectTransform anchor adjustment tool that snaps the anchors of the selected UI objects to their current Rect and zeroes the offsets (converting the current rect into anchor ratios relative to the parent), so the UI scales by anchor ratios across resolutions. It supports multi-selection batch processing and Undo.
| Namespace | OxGKit.Utilities.RectTrans.Editor |
| Type | public class RectTransformAdjuster |
| Source | RectTransformAdjuster.cs |
Reminder The hotkey is Shift+R (R: RectTransform).
Quick Start
- Select one or more UI objects in the Hierarchy (they need a
RectTransformand a parent). - Press Shift+R, or use the menu GameObject -> Adjust RectTransform Anchors (Shift+R).
- The selection's anchors snap to the current Rect, and
offsetMin/offsetMaxbecome zero (position and size stay visually unchanged).
| Menu | Description |
|---|---|
GameObject/Adjust RectTransform Anchors (Shift+R) | Snaps the selection's anchors to the current Rect (multi-selection and Undo supported). |
Attention Objects without a RectTransform or without a parent are skipped automatically and remain unchanged.
Methods
AdjustAnchors
public static void AdjustAnchors()
Performs the anchor adjustment on all currently selected objects: converts the current position and size into anchor ratios relative to the parent (anchorMin / anchorMax) and zeroes offsetMin / offsetMax; every object gets an Undo record.
Demo
Utilities Demo (RectTransformAdjuster)