logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityAchievementDefinitionSource

    Answers "which achievements does this project declare" by loading every UnityAchievementDefinition carrying the ACHIEVEMENTS Addressables label, exactly as the leaderboard loads its view definitions.

    Inheritance
    object
    UnityAchievementDefinitionSource
    Implements
    IAchievementDefinitionSource
    IAchievementConditionSource
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.Achievements.Infrastructure.Services
    Assembly: Serenity.UnityAchievements.Infrastructure.dll
    Syntax
    public sealed class UnityAchievementDefinitionSource : IAchievementDefinitionSource, IAchievementConditionSource
    Remarks

    Answers both of the questions an authored achievement holds — its definition and its unlock condition — from one pass over the assets, because reading the same folder twice to build two halves of the same thing is how the two halves drift apart.

    An asset that cannot produce a definition is reported and skipped, so a single half-authored achievement costs itself and nothing else. Which of two assets claiming the same id wins is AchievementDefinitionRegistryBuilder's policy — the later one — so both definitions are handed over intact for it to judge, and the condition map follows the same rule here so the two cannot disagree about which achievement is live.

    The load is injectable so a test can hand over ScriptableObject.CreateInstance assets without an Addressables group, an Addressables build, or a temporary asset on disk.

    Constructors

    UnityAchievementDefinitionSource(ILogService)

    Creates a source that loads the achievement assets by their Addressables label.

    Declaration
    public UnityAchievementDefinitionSource(ILogService logService)
    Parameters
    Type Name Description
    ILogService logService

    Logging service used to report an unusable asset. May be null.

    UnityAchievementDefinitionSource(Func<IReadOnlyList<UnityAchievementDefinition>>, ILogService)

    Creates a source that reads its achievement assets from the given loader.

    Declaration
    public UnityAchievementDefinitionSource(Func<IReadOnlyList<UnityAchievementDefinition>> loadDefinitionAssets, ILogService logService)
    Parameters
    Type Name Description
    Func<IReadOnlyList<UnityAchievementDefinition>> loadDefinitionAssets

    Loads the authored achievement assets. null falls back to the Addressables label load.

    ILogService logService

    Logging service used to report an unusable asset. May be null.

    Properties

    Assets

    The authored assets this source read, in load order, including the unusable ones.

    Declaration
    public IReadOnlyList<UnityAchievementDefinition> Assets { get; }
    Property Value
    Type Description
    IReadOnlyList<UnityAchievementDefinition>

    Conditions

    The authored unlock condition of each achievement that has one, by achievement id.

    Declaration
    public IReadOnlyDictionary<AchievementId, AchievementCondition> Conditions { get; }
    Property Value
    Type Description
    IReadOnlyDictionary<AchievementId, AchievementCondition>

    Methods

    GetDefinitions()

    Declaration
    public IReadOnlyList<AchievementDefinition> GetDefinitions()
    Returns
    Type Description
    IReadOnlyList<AchievementDefinition>

    Implements

    IAchievementDefinitionSource
    IAchievementConditionSource
    In this article
    © 2026 Serenity. All Rights Reserved