Class ImmediateModeGuiPass
Runs a piece of IMGUI code — an inspector's OnInspectorGUI, a window's draw — through one real
frame, with no window, no GUI view and no graphics device. EditorWindow.SendEvent is the
usual way to drive OnGUI from a test, but a headless run never delivers it, which is exactly the
run a CI or a batch verification is; this opens the same container the UI Toolkit host opens around an
IMGUIContainer, so every GUILayout call finds the state it expects.
A frame is what IMGUI runs for every repaint: a UnityEngine.EventType.Layout event, the layout calculation, then a UnityEngine.EventType.Repaint event over the rects it produced. Both events are sent, because code that writes only while it paints is as real a write-on-draw as code that writes during layout. A layout pass that ended early on an UnityEngine.ExitGUIException is not repainted: a real host abandons that frame too.
One error Unity logs during a headless repaint describes the host, not the code under test: a number field registers its drag-cursor zone while it repaints, and Unity reports that no GUI view is there to receive it (Serenity.Tests.Shared.Editor.ImmediateModeGuiPass.CursorRectOutsideGuiViewMessage). That one message is let through; every other error, assert or exception logged while repainting still fails the test that drew.
Inherited Members
Namespace: Serenity.Tests.Shared.Editor
Assembly: Serenity.Tests.Shared.Editor.dll
Syntax
public static class ImmediateModeGuiPass
Methods
RunLayoutAndRepaintPasses(Action)
Runs onGui through one IMGUI frame: a layout pass, then a repaint pass.
An UnityEngine.ExitGUIException ends a pass the way it ends a real one; any other exception reaches
the caller.
Declaration
public static void RunLayoutAndRepaintPasses(Action onGui)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | onGui |