logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityLeaderboardTopEntryService

    Locator-registered ILeaderboardTopEntryService implementation: a per-board cache refreshed in the background, read synchronously by any number of HUD-authored chains.

    Inheritance
    object
    UnityLeaderboardTopEntryService
    Implements
    ILeaderboardTopEntryService
    IService
    IFoundationSettings
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Leaderboard.Infrastructure.Services
    Assembly: Serenity.UnityLeaderboard.Infrastructure.dll
    Syntax
    public class UnityLeaderboardTopEntryService : ILeaderboardTopEntryService, IService, IFoundationSettings
    Remarks

    Replaces a scene-component cache (one board, one GameObject) with a single session-lifetime service that tracks as many boards as the HUD ever asks about. Never throws: a failed or superseded refresh leaves a board's cached entry untouched, matching the framework's never-throw-in-runtime philosophy. Boards (which allocates a new list on every access — see UnityLeaderboardSettings.Boards) and Serenity.Leaderboard.Infrastructure.Services.LeaderboardPlayerIdentityResolver.TryResolveLocalPlayer(Serenity.Leaderboard.Domain.Enums.PlayerIdentitySource,Serenity.Leaderboard.Domain.ValueObjects.PlayerId@) (backed by a native, marshalled SystemInfo.deviceUniqueIdentifier read) are both touched only once per board per refresh, never from a synchronous read. A genuine (non-cancellation) fetch failure does not retry on the very next read either: it backs off for RETRY_COOLDOWN_SECONDS, so a permanently-failing backend cannot turn a per-frame HUD read into a per-frame network call — a board's own submitted/cleared signal bypasses that cooldown, since it is fresh evidence rather than a blind retry.

    Constructors

    UnityLeaderboardTopEntryService(ILeaderboardService, ILeaderboardSettings, IEventDispatcherService, ILogService, Func<IScoreService>)

    Initializes a new instance of the UnityLeaderboardTopEntryService class.

    Declaration
    public UnityLeaderboardTopEntryService(ILeaderboardService leaderboardService, ILeaderboardSettings settings, IEventDispatcherService eventDispatcherService, ILogService logService, Func<IScoreService> scoreServiceResolver)
    Parameters
    Type Name Description
    ILeaderboardService leaderboardService

    Service every board's top-1 row is fetched through.

    ILeaderboardSettings settings

    Board configuration, player-identity source and default display name.

    IEventDispatcherService eventDispatcherService

    Dispatcher this service subscribes to for LeaderboardEntrySubmittedSignal and LeaderboardClearedSignal. May be null; the service still self-primes on first read without one, it just never proactively re-fetches on a signal.

    ILogService logService

    Logging service. May be null.

    Func<IScoreService> scoreServiceResolver

    Resolves IScoreService lazily. The Score and Leaderboard aggregates both install as independent Initialization Pipeline tasks whose relative order is configured per project (see UnityLeaderboardInstallationStep's installer), so this service cannot assume the score service already exists at construction time — it resolves through this delegate on first need and caches the first non-null result.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when leaderboardService, settings or scoreServiceResolver is null.

    Properties

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    Methods

    TryGetDisplayText(BoardId, LeaderboardFieldSelection, string, bool, out string)

    Declaration
    public bool TryGetDisplayText(BoardId board, LeaderboardFieldSelection fields, string separator, bool includeLocalPlayerScore, out string text)
    Parameters
    Type Name Description
    BoardId board
    LeaderboardFieldSelection fields
    string separator
    bool includeLocalPlayerScore
    string text
    Returns
    Type Description
    bool

    TryGetTopDisplayName(BoardId, bool, out string)

    Declaration
    public bool TryGetTopDisplayName(BoardId board, bool includeLocalPlayerScore, out string displayName)
    Parameters
    Type Name Description
    BoardId board
    bool includeLocalPlayerScore
    string displayName
    Returns
    Type Description
    bool

    TryGetTopValue(BoardId, bool, out float)

    Declaration
    public bool TryGetTopValue(BoardId board, bool includeLocalPlayerScore, out float value)
    Parameters
    Type Name Description
    BoardId board
    bool includeLocalPlayerScore
    float value
    Returns
    Type Description
    bool

    Implements

    ILeaderboardTopEntryService
    IService
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved