UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Ui Module / Area Handles System Completed

Ui Module — UGTK

Area Handles System

Summary

The Area Handles System is a rectangle the player can move and resize by dragging its corner handles, with an optional locked aspect ratio and a live readout of its width and height.

It is the crop tool: pick an area of a photo, frame a screenshot, choose the portion of an image to upload. Everything happens at runtime, in the built game — this is not an editor gizmo.


Content


Modules Dependencies

None. Two components that only use UnityEngine.EventSystems.


Setup

  1. Place the AreaHandler prefab under the canvas, over what has to be framed.
  2. Set its starting position and size from the RectTransform — the area starts exactly there.
  3. If the selection has to keep a fixed shape, turn on the aspect lock and set the ratio.

There is no GIF for the setup: it is a single prefab drop with no configuration beyond the RectTransform.


How To Use

From code:

area.SetCanEdit(false);              // freeze the selection once confirmed
area.SetKeepAspect(true);
area.SetLockedAspectRatio(16f / 9f); // width / height
string w = area.GetWidthText();      // already formatted for a label
string h = area.GetHeightText();

Good to know:


Testing Scene

Open Debug/AreaHandlesTest.unity and press Play: the area can be moved and resized, with and without the aspect lock.


Technical Info

Path Content
Scripts/Runtime/Mn_ResizableArea.cs The area: move and resize, aspect lock, size readout, SetCanEdit
Scripts/Runtime/Mn_AnchorHandles.cs One corner handle: reports its index and the drag delta to the area
Scripts/Editor/Mn_ResizableArea_Editor.cs Custom inspector
Prefabs/AreaHandler.prefab The ready-made area with its four handles
Debug/AreaHandlesTest.unity Test scene

© 2026 Marcello De Bonis. All rights reserved