logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityAchievementPlayerIdentityProvider

    Answers whose achievements these are on Unity, per the configured PlayerIdentitySource: the device identifier, or a player the game signs in and hands over.

    Inheritance
    object
    UnityAchievementPlayerIdentityProvider
    Implements
    IAchievementPlayerIdentityProvider
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Achievements.Infrastructure.Services
    Assembly: Serenity.UnityAchievements.Infrastructure.dll
    Syntax
    public class UnityAchievementPlayerIdentityProvider : IAchievementPlayerIdentityProvider
    Remarks

    Delegates the DeviceId rule to PlayerIdentityResolver rather than restating it, so achievements and leaderboards can never key the same player differently.

    A Custom project that has not signed anyone in yet falls back to the device identity and warns once. The alternative is a blank PlayerId, which is far worse than a wrong one: every player on the machine would share the empty key, so one player's unlocks would appear on another's account, and the rows would be unreachable once a real identity did arrive.

    Constructors

    UnityAchievementPlayerIdentityProvider(PlayerIdentitySource, PlayerId, ILogService)

    Initializes a new instance of the UnityAchievementPlayerIdentityProvider class.

    Declaration
    public UnityAchievementPlayerIdentityProvider(PlayerIdentitySource identitySource, PlayerId initialCustomPlayer = null, ILogService logService = null)
    Parameters
    Type Name Description
    PlayerIdentitySource identitySource

    Which source configures the resolution.

    PlayerId initialCustomPlayer

    The player used under Custom until one is signed in.

    ILogService logService

    Logging service used to report a missing custom player. May be null.

    Properties

    Current

    Declaration
    public PlayerId Current { get; }
    Property Value
    Type Description
    PlayerId

    Methods

    SetCurrentPlayer(PlayerId)

    Sets the player later reads and writes apply to under Custom.

    Declaration
    public void SetCurrentPlayer(PlayerId player)
    Parameters
    Type Name Description
    PlayerId player

    The signed-in player.

    Remarks

    Takes effect on the next LoadAsync(CancellationToken), NOT immediately: the service captures the player once per load, so a session cannot write half its unlocks under one account and half under another. A game that signs a player in — or switches profile — must therefore call LoadAsync afterwards, or it will keep writing as whoever was current when the module loaded. Ignored entirely under DeviceId, where the device answers the question.

    Implements

    IAchievementPlayerIdentityProvider
    In this article
    © 2026 Serenity. All Rights Reserved