Interface IConsoleScreen
A full-screen view that takes over the debug console's grid, draws itself, and hands the console back when it is done.
Namespace: Scylla.Console.TextMode
Assembly: ScyllaTextMode.ConsoleDisplay.dll
Syntax
public interface IConsoleScreen
Remarks
The console normally shows a scrolling log with a command line under it. A screen replaces that for as long as it runs: the terminal switches to its alternate grid, the command line stops taking input, and the screen owns every cell. Closing it restores the log exactly as it was, scroll position and all, because the two grids are kept separately rather than one being redrawn over the other.
Use this for anything that wants the whole console rather than a few lines of output: a log viewer with its own navigation, a live stats page, a settings editor, a game. Push one with PushScreen(IConsoleScreen), which only the Terminal Emulation display backend provides; the TextMeshPro backends render a single styled string and have no grid to give away.
A screen reads input itself, from Keyboard.current or any other source, because
the console suspends its own command line while one is open. It should offer a way out
and report it through IsFinished; there is no key the console reserves on
a screen's behalf.
The shape of an implementation:
public sealed class ClockScreen : IConsoleScreen
{
private UITextModeView _view;
private DebugConsoleColorScheme _colors;
public bool IsFinished { get; private set; }
public void OnOpen(UITextModeView view, DebugConsoleColorScheme colors)
{
_view = view;
_colors = colors;
}
public void OnUpdate(float deltaTime)
{
if (Keyboard.current != null && Keyboard.current.qKey.wasPressedThisFrame)
{
IsFinished = true;
return;
}
_view.Grid.Clear();
/* draw with _view.SetCell(...) */
}
public void OnClose() => _view = null;
}
Properties
IsFinished
Gets whether the screen has finished and wants the console back.
Declaration
bool IsFinished { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
OnClose()
Called once as the screen closes, whether it finished on its own or the console took it down.
Declaration
void OnClose()
Remarks
The console closes an open screen when it is hidden or destroyed, so this is the place to release anything the screen holds. The grid handed to OnOpen(UITextModeView, DebugConsoleColorScheme) must not be touched after this returns.
OnOpen(UITextModeView, DebugConsoleColorScheme)
Called once as the screen opens, handing it the grid it draws into.
Declaration
void OnOpen(UITextModeView view, DebugConsoleColorScheme colors)
Parameters
| Type | Name | Description |
|---|---|---|
| UITextModeView | view | The view the console has switched onto its alternate grid. Its Rows and Columns are whatever the console is currently sized to, so a screen should lay itself out from those rather than assume a size. The grid arrives holding whatever a previous screen left in it; clear it through Grid if a blank start matters. |
| DebugConsoleColorScheme | colors | The console's current theme. Draw from these rather than from fixed colors: the console is themed by palette and a project may well be running a light one, where hard-coded white text would be invisible. |
Remarks
Draw through SetCell(int, int, uint, Color32, Color32, CellAttributes) rather than writing to the grid directly. The view looks the glyph up in the font atlas and stamps its texture coordinates into the cell; a cell written straight to the grid carries a codepoint with no atlas data behind it, and renders as a blank block of background.
Pass DefaultBackground as the cell background unless a block of color is actually wanted. The console sets that fully transparent so its gradient shows through the text, and an opaque background stamps a flat rectangle over the gradient behind every character drawn.
The theme is handed over once, as the screen opens. A screen that outlives a live theme change keeps the colors it was given until it is reopened.
OnUpdate(float)
Called once per frame while the screen is open, to read input and redraw.
Declaration
void OnUpdate(float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deltaTime | Seconds since the previous frame, scaled by the framework's time. |
Remarks
The console does not redraw anything on a screen's behalf, so a screen that draws nothing shows the frame it last drew. That is a reasonable way to run: draw on change rather than every frame, since the grid keeps its contents.