Class UnityLeaderboardBestEntryCache
Gameplay MonoBehaviour that keeps a synchronous, always-current cache of the local player's best entry on one leaderboard board, so a HUD element can bind to it directly.
Namespace: Serenity.Leaderboard.Infrastructure.Components
Assembly: Serenity.UnityLeaderboard.Infrastructure.dll
Syntax
public class UnityLeaderboardBestEntryCache : MonoBehaviour
Remarks
ILeaderboardService is fully async end-to-end, but a HUD binding only ever reads a
synchronous member chain (see the HUD cookbook's "Bindings are chains, not single members"). This
component closes that gap: it queries GetPlayerRankAsync(BoardId, PlayerId, CancellationToken) in the
background and exposes the last known result through
TryGetBestValue(out float)/BestValue/HasValue, plain synchronous reads a
SCENE_OBJECT HUD binding can chain into. Never throws: a cancelled or failed query leaves the
previously cached value untouched, matching the framework's never-throw-in-runtime philosophy. A
query that genuinely SUCCEEDS with no entry for the player (e.g. after ClearAsync) clears the
cache instead of keeping a stale record.
Constructors
UnityLeaderboardBestEntryCache()
Declaration
public UnityLeaderboardBestEntryCache()
Properties
BestValue
The last cached best value, or 0 when no value has been fetched yet.
Declaration
public float BestValue { get; }
Property Value
| Type | Description |
|---|---|
| float |
HasValue
Whether a value has been fetched from the leaderboard at least once.
Declaration
public bool HasValue { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
Refresh()
Re-queries the configured board for the local player's best entry, fire-and-forget. A no-op while the component is disabled — subscription and refresh retries are the lifecycle's job (Serenity.Leaderboard.Infrastructure.Components.UnityLeaderboardBestEntryCache.OnEnable), not something a stray public call should trigger on a disabled instance.
Declaration
public void Refresh()
TryGetBestValue(out float)
Try-style read for a HUD binding: the return value is the found flag, value the
cached best value.
Declaration
public bool TryGetBestValue(out float value)
Parameters
| Type | Name | Description |
|---|---|---|
| float | value | The cached best value, or |
Returns
| Type | Description |
|---|---|
| bool |
|