Class PreviewOverlayGui
Draws the preview's interaction chrome: hover and selection outlines, the selected element's transform handles, id and readout chips, and the per-handle cursor.
Inherited Members
Namespace: Serenity.Ui.Infrastructure.Editor.Preview
Assembly: Serenity.UnityUi.Infrastructure.Editor.dll
Syntax
public static class PreviewOverlayGui
Remarks
The quad outline and fill are the first use of UnityEditor.Handles in this codebase; every existing
preview outline (SerenityUiPreviewWindow.DrawOutline) is axis-aligned UnityEditor.EditorGUI.DrawRect(UnityEngine.Rect,UnityEngine.Color),
which cannot follow a rotated element. UnityEditor.Handles calls only work inside an IMGUI window when
wrapped in UnityEditor.Handles.BeginGUI/UnityEditor.Handles.EndGUI — the caller is responsible for that,
and for translating quads into whatever clip the drawing is happening inside.
Methods
ApplyCursor(Rect, MouseCursor)
Registers a cursor rect for this repaint, so the pointer changes while it hovers the area.
Declaration
public static void ApplyCursor(Rect rect, MouseCursor cursor)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | The screen-space area the cursor applies over. |
| MouseCursor | cursor | The cursor to show; UnityEditor.MouseCursor.Arrow is treated as "leave it alone". |
CursorFor(float)
Buckets a frame-space direction into one of Unity's four resize cursors.
Declaration
public static MouseCursor CursorFor(float directionDegrees)
Parameters
| Type | Name | Description |
|---|---|---|
| float | directionDegrees | The direction to bucket, in degrees; any range is accepted. |
Returns
| Type | Description |
|---|---|
| MouseCursor | The bucketed resize cursor. |
Remarks
A resize cursor points both ways along its axis, so opposite directions 180° apart always share a bucket — an 8-way handle layout needs only 4 distinct cursors.
CursorForHandle(PreviewQuad, PreviewHandle)
The cursor a handle should show, bucketed from the direction it actually drags the element in.
Declaration
public static MouseCursor CursorForHandle(PreviewQuad quad, PreviewHandle handle)
Parameters
| Type | Name | Description |
|---|---|---|
| PreviewQuad | quad | The element's quad. |
| PreviewHandle | handle | The handle to find a cursor for. |
Returns
| Type | Description |
|---|---|
| MouseCursor | The cursor to display. |
DrawElementChip(Vector2, string)
Draws a small label chip naming the hovered element.
Declaration
public static void DrawElementChip(Vector2 anchorPoint, string elementId)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | anchorPoint | Frame-space point to anchor the chip above. |
| string | elementId | The element's id. |
DrawGestureReadoutChip(Vector2, string)
Draws a small chip reporting the current gesture's live value.
Declaration
public static void DrawGestureReadoutChip(Vector2 anchorPoint, string readout)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | anchorPoint | Frame-space point to anchor the chip above. |
| string | readout | The formatted value, from FormatReadout(PreviewGestureKind, HudOffset, float, float, float). |
DrawHoverFill(PreviewQuad)
Draws the hover treatment: a faint outline plus a faint fill.
Declaration
public static void DrawHoverFill(PreviewQuad quad)
Parameters
| Type | Name | Description |
|---|---|---|
| PreviewQuad | quad | The hovered element's quad. |
DrawParentedNote(Vector2)
Draws a small note that a parented element's own Anchor and Offset are ignored — its parent's box places it instead, so there is nothing for a drag gesture on it to usefully write.
Declaration
public static void DrawParentedNote(Vector2 anchorPoint)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | anchorPoint | Frame-space point to anchor the note above. |
DrawQuadOutline(PreviewQuad, Color, float)
Draws a quad's outline.
Declaration
public static void DrawQuadOutline(PreviewQuad quad, Color color, float thickness)
Parameters
| Type | Name | Description |
|---|---|---|
| PreviewQuad | quad | The quad to outline, in whatever space the caller is currently drawing. |
| Color | color | The outline colour. |
| float | thickness | The outline thickness, in pixels. |
DrawRotationHandle(PreviewQuad, bool)
Draws the rotation handle: a stick from the element's top edge, ending in a grabbable knob.
Declaration
public static void DrawRotationHandle(PreviewQuad quad, bool isActive)
Parameters
| Type | Name | Description |
|---|---|---|
| PreviewQuad | quad | The selected element's quad. |
| bool | isActive | Whether the knob is currently grabbed or hovered, drawn highlighted. |
Remarks
The corner rotate band is a pro shortcut; this is the discoverable affordance — the classic PowerPoint/Figma/Sprite-Editor "lollipop". Both drive the same rotate gesture through IsRotateHandle(PreviewHandle).
DrawSelectionOutline(PreviewQuad, float)
Draws the selected element's pulsing outline.
Declaration
public static void DrawSelectionOutline(PreviewQuad quad, float pulse)
Parameters
| Type | Name | Description |
|---|---|---|
| PreviewQuad | quad | The selected element's quad. |
| float | pulse | Alpha multiplier, expected to breathe between roughly 0.1 and 1 over time. |
DrawTransformHandles(PreviewQuad, PreviewHandle)
Draws the eight scale handles around the selected element's quad.
Declaration
public static void DrawTransformHandles(PreviewQuad quad, PreviewHandle activeHandle)
Parameters
| Type | Name | Description |
|---|---|---|
| PreviewQuad | quad | The selected element's quad. |
| PreviewHandle | activeHandle | The handle currently grabbed or hovered, drawn highlighted. |
FormatReadout(PreviewGestureKind, HudOffset, float, float, float)
Formats a gesture's live value the way its readout chip shows it.
Declaration
public static string FormatReadout(PreviewGestureKind kind, HudOffset offset, float effectiveScaleX, float effectiveScaleY, float rotationDegrees)
Parameters
| Type | Name | Description |
|---|---|---|
| PreviewGestureKind | kind | What the gesture is doing. |
| HudOffset | offset | The element's current authored offset. |
| float | effectiveScaleX | The element's current scale times its X stretch. |
| float | effectiveScaleY | The element's current scale times its Y stretch. |
| float | rotationDegrees | The element's current authored rotation, in degrees. |
Returns
| Type | Description |
|---|---|
| string | The chip's text. |