Class HudRepeatedSpriteRenderer
Draws a quantity as a row of sprites: one per unit, optionally with the spent slots still visible, and optionally collapsing to a single sprite plus a count once the quantity gets large.
Inherited Members
Namespace: Serenity.GameUi.Infrastructure.Representations
Assembly: Serenity.UnityGameUi.Infrastructure.dll
Syntax
public sealed class HudRepeatedSpriteRenderer : IHudRepresentationRenderer, IHudValueColorable
Remarks
Shared by the stack and segmented representations, which differ only in whether the empty slots are drawn and whether collapsing is allowed. Both need a capacity: without a maximum there is no way to know how many slots exist, which is why the representation rules make it mandatory.
The slot objects are created once, up to the capacity, and then only toggled. Rebuilding them on every change would allocate and force a full layout pass each time the player fires a shot.
Constructors
HudRepeatedSpriteRenderer(Func<UnityUiThemeHudStyle, HudRepeatedSpriteSettings>)
Creates a renderer for one repeated-sprite representation.
Declaration
public HudRepeatedSpriteRenderer(Func<UnityUiThemeHudStyle, HudRepeatedSpriteSettings> settingsFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<UnityUiThemeHudStyle, HudRepeatedSpriteSettings> | settingsFactory | Produces the drawing options from the theme's HUD style. Deferred rather than passed directly because the theme is only known once the element is being built. |
Methods
Apply(CompiledHudBinding, CompiledHudBinding)
Updates the visuals from the current binding values.
Declaration
public void Apply(CompiledHudBinding value, CompiledHudBinding capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| CompiledHudBinding | value | The element's value binding. |
| CompiledHudBinding | capacity | The element's capacity binding, or null when it has none. |
ApplyValueColor(Color)
Colours the representation's value for as long as it stays in its current threshold band.
Declaration
public void ApplyValueColor(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | color | The band's authored colour. |
Remarks
Tints filled slots only — an empty slot keeps its authored empty colour regardless of any band. The
override is a field consulted by Serenity.GameUi.Infrastructure.Representations.HudRepeatedSpriteRenderer.ApplySlot(UnityEngine.UI.Image,System.Boolean), not a mutation of Serenity.GameUi.Infrastructure.Representations.HudRepeatedSpriteRenderer._settings, so
a slot rebuild triggered by a capacity change (Serenity.GameUi.Infrastructure.Representations.HudRepeatedSpriteRenderer.EnsureSlotCount(System.Int32) plus a fresh pass over
every slot in Serenity.GameUi.Infrastructure.Representations.HudRepeatedSpriteRenderer.RenderSlots(System.Int32,System.Int32) or Serenity.GameUi.Infrastructure.Representations.HudRepeatedSpriteRenderer.RenderCollapsed(System.Int32)) repaints every filled slot —
old and newly created alike — through this same override automatically. Repainting here as well
covers the other case: a band change with no rebuild at all, which is exactly the change Apply's
own filled/capacity cache would otherwise swallow.
Build(RectTransform, HudRenderResources)
Builds the visuals under the element's container.
Declaration
public void Build(RectTransform container, HudRenderResources resources)
Parameters
| Type | Name | Description |
|---|---|---|
| RectTransform | container | The element's anchored container. |
| HudRenderResources | resources | Theme-derived building blocks. |
Remarks
The resources carry the theme's HUD style, so chrome is resolved here rather than baked when the renderer is created: a representation does not know which theme it will be drawn under.
ClearValueColor()
Restores whatever colour the representation had before any threshold band applied.
Declaration
public void ClearValueColor()