A lightweight Unity Editor tool that adds customizable keyboard shortcuts to snap UI elements to specific positions within their parent. Designed to speed up UI layout workflows and reduce repetitive clicks in the Editor.
Building precise UI layouts in Unity often requires manually dragging RectTransforms or using the default alignment tools. This is:
- Slow and repetitive
- Error-prone for large UI hierarchies
- Tedious when frequent adjustments are needed
UI Element Alignment Shortcuts introduces keyboard-driven snapping, letting developers align selected UI elements instantly with one hand, improving workflow and precision.
- Multiple clicks needed to align objects
- Aligning many elements in complex hierarchies is slow
- Default Unity tools do not support quick keyboard shortcuts
- Inefficient for prototyping, menus, HUDs, and in-game overlays
A single editor script that listens for key events in editor mode and snaps selected UI elements to predefined positions relative to their parent:
- Top-Left, Top-Center, Top-Right
- Middle-Left, Middle-Center, Middle-Right
- Bottom-Left, Bottom-Center, Bottom-Right
Supports:
- Multi-selection snapping
- Immediate feedback in Scene view
- Configurable shortcuts
- 9 predefined positions (like numpad layout) for fast alignment
- Positions relative to parent RectTransform
- Maintains current pivot and anchors
- Default mapping:
Alt + 1-9(configurable) - Supports multi-selection snapping
- Non-intrusive, editor-only key handling
- Snap multiple UI elements simultaneously
- Preserves relative offsets if desired (optional)
- One script, no additional Editor windows
- Zero runtime overhead
- Compatible with both UGUI and Canvas systems
- Save time during HUD, menu, or popup design
- Reduce errors in precise layouts
- Quick adjustments during iterative prototyping
- Rapidly align UI buttons, panels, and HUD elements
- Standardize layout across screens
- Streamline level UI builds
- Quickly test multiple alignments
- Ensure consistent padding and spacing
- Reduce repetitive dragging and Inspector adjustments
- Validate UI layouts across resolutions
- Fix alignment issues quickly without extra clicks
Editor/
└── UIElementAlignmentShortcuts.cs
- Subscribes to
SceneView.duringSceneGui - Detects key presses (Alt + 1-9)
- Checks for selected UI elements
- Computes target position within parent RectTransform
- Adjusts
anchoredPositionwhile preserving pivot and size - Supports optional offset preservation
- Iterates over all selected elements
- Applies snap logic individually
- Copy the script to your project:
Assets/Editor/UIElementAlignmentShortcuts/
- Open Unity
- The shortcuts automatically work in the Scene view for selected UI elements
- Editor-only execution; no runtime impact
- Minimal overhead even in large scenes
- Undo system integration via
Undo.RecordObject - Non-destructive; can revert alignment with standard Undo (
Ctrl+Z)
- Unity 2020 LTS and above
- UGUI / Canvas system
- Built-in, URP, and HDRP
- Works with version control (Git, Perforce)
Contributions welcome:
- Shortcut customization improvements
- Performance enhancements
- UI feedback or visualization features
Fork the repo and submit a pull request with proper documentation.
MIT License
Free to use, modify, and distribute in personal or commercial projects.
This tool exists because UI alignment should be fast and painless.
It empowers developers and designers to:
Snap UI elements instantly, reduce repetitive clicks, and maintain precise layouts effortlessly.
Open an issue in the repository for bugs, suggestions, or feature requests.
Happy and fast UI designing