Class TextModeCRTDriver
Shows a TextMode view through a simulated cathode ray tube: scanlines, phosphor mask, afterglow, glow and a curved screen.
Inherited Members
Namespace: Scylla.TextMode.CRT
Assembly: ScyllaTextMode.CRT.dll
Syntax
[ExecuteAlways]
[DisallowMultipleComponent]
[DefaultExecutionOrder(1000)]
[AddComponentMenu("Scylla/TextMode/TextMode CRT")]
public sealed class TextModeCRTDriver : MonoBehaviour
Remarks
Add it to the GameObject that holds a UITextModeView and assign a preset. The view keeps its grid, its input and its selection; the driver renders the grid at exact cell pixels every frame, runs the tube simulation on that raster, and shows the result through a TextModeCRTScreen it creates as a child of the view. It also installs the screen as the view's pointer mapper, so clicks and selection follow the curved picture. Disabling the driver restores the plain view.
The driver works in every render pipeline, because it uses only command buffers and a uGUI graphic. When the TextMode module is present and disabled, the driver stops all of its work and shows the plain view, keeping its textures for when the module returns.
The settings the driver uses start as a copy of its preset. Change them through Settings at any time; ResetToPreset() copies the preset again.
The driver does its work in LateUpdate with a high execution order, after the view
has updated its grid. Each frame it copies and sanitizes the settings, places the tube
inside the view's rect, captures the grid, records the raster, signal, afterglow, glow and
burn-in passes into a command buffer, and hands the textures to the
TextModeCRTScreen. OnDisable gives drawing back to the view and
releases the command buffer and the pass chain textures; OnDestroy destroys the
screen object the driver created. All of this runs on the main thread.
The driver needs a UITextModeView on the same GameObject, or an ITextModeViewHost such as TextModeTerminalHost, whose view it uses once the host has created it. Without either it logs a warning once and does nothing until a view is added. For a world-space TextModeView use TextModeCRTMonitor, and for a whole camera picture use TextModeCRTImageRenderer through a render pipeline integration.
The following example adds the CRT to an existing UI view from code, then switches the tube off and on again.
var crt = view.gameObject.AddComponent<TextModeCRTDriver>();
crt.Preset = myPreset;
crt.QualityTier = CRTQualityTier.High;
crt.Settings.ScanlinePitch = 3;
crt.Tube.PowerOff();
crt.Tube.PowerOn();
Properties
HDRHeadroom
Gets the display's headroom for the last frame, peak luminance over paper white, including a manual override. 1 on a standard display.
Declaration
public float HDRHeadroom { get; }
Property Value
| Type | Description |
|---|---|
| float |
HDRMaskActive
Gets whether HDR mask mode was active for the last frame: the settings ask for it, the display shows HDR with enough headroom, and the view's canvas can show light above paper white.
Declaration
public bool HDRMaskActive { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsActive
Gets whether the CRT is currently showing the view.
Declaration
public bool IsActive { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Preset
Gets or sets the preset. Assigning a preset copies its settings into Settings.
Declaration
public TextModeCRTPreset Preset { get; set; }
Property Value
| Type | Description |
|---|---|
| TextModeCRTPreset |
QualityTier
Gets or sets the quality tier. Setting it also stops following the project defaults.
Declaration
public CRTQualityTier QualityTier { get; set; }
Property Value
| Type | Description |
|---|---|
| CRTQualityTier |
ReadabilityClamp
Gets or sets whether the readability clamp is on. Setting it also stops following the project defaults.
Declaration
public bool ReadabilityClamp { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
ResolvedSettings
Gets the settings used for the last frame, after clamping.
Declaration
public TextModeCRTSettings ResolvedSettings { get; }
Property Value
| Type | Description |
|---|---|
| TextModeCRTSettings |
Screen
Gets the screen graphic, or null before the first frame.
Declaration
public TextModeCRTScreen Screen { get; }
Property Value
| Type | Description |
|---|---|
| TextModeCRTScreen |
Settings
Gets the settings this driver uses, before the readability clamp. Change them freely; changes take effect on the next frame.
Declaration
public TextModeCRTSettings Settings { get; }
Property Value
| Type | Description |
|---|---|
| TextModeCRTSettings |
Tube
Gets or sets the tube: switch it on and off, degauss it, or clear its burn-in. The driver starts with its own tube, switched on. Assign another to share one tube between a driver and a camera effect; null is ignored.
Declaration
public TextModeCRTTube Tube { get; set; }
Property Value
| Type | Description |
|---|---|
| TextModeCRTTube |
UseProjectDefaults
Gets or sets whether the quality tier and the readability clamp follow the TextMode configuration.
Declaration
public bool UseProjectDefaults { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
ApplyPreset(TextModeCRTPreset)
Assigns a preset and copies its settings into Settings, replacing any changes made since.
Declaration
public void ApplyPreset(TextModeCRTPreset preset)
Parameters
| Type | Name | Description |
|---|---|---|
| TextModeCRTPreset | preset | The preset to use. Null keeps the current settings and clears the preset. |
ResetToPreset()
Copies the preset's settings again, discarding changes made since it was applied.
Declaration
public void ResetToPreset()