Skip to main content

MapBoardRenderer

A class in Root.Township, Alta.Map.

Client: renders a map board's UI canvas into a render texture with a shared hidden camera, re-rendering when landmarks change. Destroys itself on headless servers.

Constructors​

MemberWhat it is
MapBoardRenderer()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

8 private and internal fields
MemberWhat it is
private static readonly int _MapTextureShader property ID for _MainTex.
private bool isRenderingGuards against a render starting during another one or after destroy.
private bool isRenderQueuedTrue while a delayed render is pending.
private bool isVisibleWhether the board's renderer is currently seen by a camera.
private bool needToRenderSet when a change came in while hidden.
private static Camera renderCameraOne orthographic camera shared by every map board, created on first use and kept disabled.
private RenderTexture renderTextureTemporary render texture sized to the canvas, shown on this object's material.
private Canvas targetCanvasThe UI canvas that is rendered; kept disabled except while rendering.

Methods​

7 private and internal methods
MemberWhat it is
private void Awake()Destroys itself on headless builds. Otherwise makes the render texture and shared camera, renders once and listens for landmark changes.
private void CheckRender(MarkerInfo marker)On landmark change, queues a render if visible, otherwise marks that one is needed.
private void OnBecameInvisible()Marks the board as not visible so renders are put off.
private void OnBecameVisible()Marks the board visible and renders if a change came in while hidden.
private void OnDestroy()Releases the render texture and removes the landmark listener.
private void QueueRender()Schedules RenderMap 0.5 s later, unless one is already queued.
private void RenderMap()Turns the canvas on, renders it with renderCamera into the texture, then turns it off again.