Class TextModeCRTScreen
The uGUI graphic that shows the CRT picture. It covers the view it belongs to and draws the tube at screen resolution from the textures the TextModeCRTDriver prepares.
Inheritance
Inherited Members
Namespace: Scylla.TextMode.CRT
Assembly: ScyllaTextMode.CRT.dll
Syntax
[ExecuteAlways]
[DisallowMultipleComponent]
[RequireComponent(typeof(CanvasRenderer))]
[AddComponentMenu("")]
public sealed class TextModeCRTScreen : MaskableGraphic, ICanvasElement, IClippable, IMaskable, IMaterialModifier, ITextModePointerMapper
Remarks
The driver creates and owns this graphic as a child of the view, so parent masks, clip rects and canvas groups apply to it exactly as they applied to the view. Do not add it by hand.
It also maps pointer positions through the tube's curvature, which the driver installs as the view's PointerMapper, so selection and mouse input hit the cell that is actually shown under the pointer.
The graphic does not raise pointer events itself (raycastTarget is off), so clicks
reach the view below it. It is filled from LateUpdate of the driver through the
internal Present method, and it draws nothing until the first frame has been
presented. It owns one composite material, created on demand and destroyed in
OnDestroy.
Properties
TubePixels
Gets the size of the tube in output pixels.
Declaration
public Vector2 TubePixels { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
TubeRect
Gets the area the tube covers, in the graphic's local coordinates.
Declaration
public Rect TubeRect { get; }
Property Value
| Type | Description |
|---|---|
| Rect |
Methods
Awake()
Unity message. Turns off raycastTarget so the graphic never blocks pointer input to
the view below it.
Declaration
protected override void Awake()
Overrides
OnDestroy()
Unity message. Destroys the composite material this graphic created.
Declaration
protected override void OnDestroy()
Overrides
OnPopulateMesh(VertexHelper)
Builds one quad covering the tube, or with a bezel the whole area, so the bezel runs out to the edges instead of leaving the view's own background beside it. The texture coordinate runs from 0 to 1 across the tube and past that range over the bezel, which is how the composite tells them apart.
Declaration
protected override void OnPopulateMesh(VertexHelper vh)
Parameters
| Type | Name | Description |
|---|---|---|
| VertexHelper | vh | The vertex helper to fill. It is cleared first, and stays empty until a frame is presented. |
Overrides
TryMapScreenPoint(Vector2, Camera, out Vector2)
Maps a screen position to a position on the view's grid, following the curvature of the tube.
Declaration
public bool TryMapScreenPoint(Vector2 screenPoint, Camera eventCamera, out Vector2 gridUV)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | screenPoint | The pointer position in screen pixels. |
| Camera | eventCamera | The camera of the canvas, or null for a Screen Space Overlay canvas. |
| Vector2 | gridUV | On success, the position on the grid from 0 to 1, with (0, 0) at the top-left corner of the grid. Zero when the method returns false. |
Returns
| Type | Description |
|---|---|
| bool | True if the pointer is over the picture; false before the first frame has been presented, or when the position is outside the tube or in the bezel or the curved-away corners. |
Remarks
The position inside the tube is warped with the same curvature the picture uses, so the result is the cell that is shown under the pointer.