Skip to main content

RectTransformAdjuster

Important Attention Reminder

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.

NamespaceOxGKit.Utilities.RectTrans.Editor
Typepublic class RectTransformAdjuster
SourceRectTransformAdjuster.cs

Reminder The hotkey is Shift+R (R: RectTransform).

Quick Start

  1. Select one or more UI objects in the Hierarchy (they need a RectTransform and a parent).
  2. Press Shift+R, or use the menu GameObject -> Adjust RectTransform Anchors (Shift+R).
  3. The selection's anchors snap to the current Rect, and offsetMin / offsetMax become zero (position and size stay visually unchanged).
MenuDescription
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)