Class MinimapCameraRenderer
Owns the overhead camera that photographs the world for the minimap, and renders it at a capped rate into a texture the UI draws.
public sealed class MinimapCameraRenderer : IDisposable
- Inheritance
-
MinimapCameraRenderer
- Implements
- Inherited Members
Remarks
Why the camera is disabled and rendered by hand. A Camera component
that is enabled renders its target once per frame, for as long as it is enabled, whether or
not anything is looking at the result. A minimap does not need sixty overhead renders of
the world every second — it needs about thirty, and only while it is on screen. Keeping the
component disabled and submitting an explicit render request is the supported way to say
that under a scriptable render pipeline; FramesPerSecond then costs what it
says it costs.
Why every setting is re-applied on every render. The camera's field of view is the one piece of the map subsystem that turns into real information when it is widened: a client that doubles the orthographic size gets a genuinely larger photograph of the world than it is meant to have. Setting the size once at start-up leaves that value sitting in a component for the rest of the session; re-applying the whole configuration each time means any tampering survives at most one frame — and, just as importantly, that a camera assigned in a scene cannot silently contribute a stale culling mask or a clipping plane that hides the ground. The previous minimap did exactly that, and shipped for months rendering nothing but black because the scene's far clip plane sat precisely on the terrain.
What it does not defend against. A process that can edit the camera's memory can also edit this. The point is not that widening is impossible; it is that widening the picture reveals terrain, which is public, and never reveals a marker — markers are drawn by the UI from MapMarkerFilter, which is a different code path with its own rules, fed only by entities the server chose to stream.
Fields
CameraDepth
How far below the follow target the camera can still see, in metres.
public const float CameraDepth = 900
Field Value
Remarks
Added to CameraHeight to give the far plane. Generous because a player standing on a tower must still see the ground at the bottom of the valley below them, and because the cost of an over-long orthographic depth range is precision in the depth buffer rather than anything the player can see on a top-down view of static terrain.
CameraHeight
How far above the follow target the camera sits, in metres.
public const float CameraHeight = 400
Field Value
Remarks
High enough to clear any terrain or building the player can stand under, low enough that the near plane can stay small without the depth range becoming useless. The old value was 1000 against a far plane of 1000, which put the ground exactly on the far plane and clipped the entire world away.
Properties
FramesPerSecond
How many times a second the world is photographed.
public float FramesPerSecond { get; set; }
Property Value
Remarks
Zero or less means "every frame", which is what the old minimap did implicitly. Values are clamped by the caller from the player's setting rather than here, so that a deliberate uncapped mode stays expressible.
IsReady
Whether the renderer has a camera and a texture and can be asked to render.
public bool IsReady { get; }
Property Value
Texture
The texture the UI should draw. Null until Configure(Camera, LayerMask, int) has run.
public RenderTexture Texture { get; }
Property Value
- RenderTexture
Methods
Configure(Camera, LayerMask, int)
Prepares the camera and its texture.
public void Configure(Camera existing, LayerMask additionalLayers, int pixelResolution)
Parameters
existingCameraA camera assigned in the scene to use instead of creating one. Its entire configuration is overwritten. May be null.
additionalLayersLayerMaskExtra layers to photograph beyond the defaults.
pixelResolutionintEdge length of the render texture, in pixels.
Remarks
Safe to call again with a different resolution: the texture is rebuilt only when the size actually changes, so a settings panel can push the value on every slider frame.
Dispose()
Destroys the texture, and the camera if this renderer created it.
public void Dispose()
Render(MapViewTransform, bool)
Renders the world into Texture if the frame cap allows it.
public bool Render(MapViewTransform view, bool force = false)
Parameters
viewMapViewTransformThe window to photograph.
forceboolRender now regardless of the frame cap.
Returns
- bool
True when a render was submitted.
Remarks
The unscaled clock, so a paused or slowed game still updates the map. Time scale is a gameplay concept and the minimap is a readout of where things are, not a simulation of them.