Class UnityAchievementsPanel
Script on an achievements panel (theme's AchievementsTemplate, or the procedural fallback built
by CreateProcedural(Transform)): a header, a points-summary slot, the container the achievement rows
are built into, an empty-state slot, and a Back button. Filled and driven by
UnityAchievementsView.
Namespace: Serenity.Achievements.Infrastructure.Views
Assembly: Serenity.UnityAchievements.Infrastructure.dll
Syntax
public sealed class UnityAchievementsPanel : MonoBehaviour
Remarks
Rows are pooled rather than rebuilt: a listing refreshes on every unlock, on every progress change and on every screenshot capture, and destroying a hundred row hierarchies per unlock is the difference between a refresh nobody notices and a visible hitch. Rows past the current count are deactivated, not destroyed, so the next longer list reuses them.
Intentionally Unity-only, mirroring UnityLeaderboardPanel: a MonoBehaviour authored on a
theme prefab (or built procedurally) and driven only by the view in the same module.
Constructors
UnityAchievementsPanel()
Declaration
public UnityAchievementsPanel()
Properties
VisibleRows
The rows currently shown, in display order. Pooled rows past the count are excluded.
Declaration
public IReadOnlyList<UnityAchievementRowView> VisibleRows { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<UnityAchievementRowView> |
Methods
ConfigureBackButton(Action)
Routes the Back button to the view's return handling, and hides the button when there is none.
Declaration
public void ConfigureBackButton(Action backRequested)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | backRequested | What the button does, or |
ConfigureScroll(int)
Records how many rows fit before the list scrolls; applied on the next SetRows(IReadOnlyList<AchievementRowContent>, Func<string, Sprite>, bool).
Declaration
public void ConfigureScroll(int visibleRowCount)
Parameters
| Type | Name | Description |
|---|---|---|
| int | visibleRowCount | How many rows are visible before scrolling (0 = no clamp). |
CreateProcedural(Transform)
Builds a minimal, unthemed panel under parent for when no theme AchievementsTemplate is configured.
Declaration
public static UnityAchievementsPanel CreateProcedural(Transform parent)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | parent | The transform the procedural panel is parented under. |
Returns
| Type | Description |
|---|---|
| UnityAchievementsPanel | The configured (still title-less, row-less) panel. |
ScrollBy(float)
Scrolls the clamped rows area, so a gamepad or the arrow keys can reach past the visible rows. A panel that is not clamped ignores this: there is nothing off-screen to reach.
Declaration
public void ScrollBy(float normalizedDelta)
Parameters
| Type | Name | Description |
|---|---|---|
| float | normalizedDelta | How far to scroll, as a fraction of the whole list. Positive scrolls down. |
SetEmptyState(bool, string)
Shows or hides the empty-state holder, setting its message when shown.
Declaration
public void SetEmptyState(bool visible, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | visible | Whether the empty-state holder should be shown. |
| string | message | The message to display when |
SetPointsSummary(string)
Sets the points-summary text, hiding its holder when there is none to show.
Declaration
public void SetPointsSummary(string summary)
Parameters
| Type | Name | Description |
|---|---|---|
| string | summary | The "earned / maximum" line, or null/empty to hide the slot. |
SetRows(IReadOnlyList<AchievementRowContent>, Func<string, Sprite>, bool)
Fills the rows container with one row per entry, reusing the pooled row objects and hiding the surplus.
Declaration
public void SetRows(IReadOnlyList<AchievementRowContent> rows, Func<string, Sprite> resolveIcon, bool showThumbnails)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<AchievementRowContent> | rows | The already-formatted rows to display, in order. |
| Func<string, Sprite> | resolveIcon | Answers an achievement's authored icon by id. May be |
| bool | showThumbnails | Whether unlock screenshots are shown for rows that have one. |
SetTitle(string, bool)
Sets the header text, hiding the header holder when the title is empty.
Declaration
public void SetTitle(string title, bool isTranslating = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | title | The header text, or its localization key when |
| bool | isTranslating | Whether the title is a localization key rather than literal text. |