logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class AchievementSyncAssetWriter

    Applies — or previews applying — the ACCEPTED Pull-direction changes of an AchievementSyncPlan to the project's authored achievement assets and string tables.

    Inheritance
    object
    AchievementSyncAssetWriter
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.Achievements.Infrastructure.Editor.Sync
    Assembly: Serenity.UnityAchievements.Infrastructure.Editor.dll
    Syntax
    public sealed class AchievementSyncAssetWriter
    Remarks

    Shaped like Serenity.ProjectRecipe.Infrastructure.Editor.SerenityRecipeAssetDatabase: the constructor takes PreviewOnly, and every write path decides what it would do — validates, resolves what changed, builds the report entry — before the one line that actually mutates anything, so a preview and a real apply share one code path and differ only in whether that one line runs.

    Every asset mutation is routed through AchievementDefinitionCreator — the sanctioned writer of achievement definition assets — or, for localized text, through the string-table write extension on Serenity.Global.Infrastructure.Editor.UnityLocalizationStringTableEditorUtils. This class never touches an asset's UnityEngine.Object fields directly. A creation from a storefront-only row is Serenity.Achievements.Infrastructure.Editor.Sync.AchievementSyncPlatformOnlyCreator's, a key adoption is Serenity.Achievements.Infrastructure.Editor.Sync.AchievementSyncKeyAdopter's, and both file their text through Serenity.Achievements.Infrastructure.Editor.Sync.AchievementSyncTranslatedEntryWriter. An icon row is Serenity.Achievements.Infrastructure.Editor.Sync.AchievementSyncPulledIcons's: it downloads the image through the request's icon source and saves it as a sprite, and a preview reports it without downloading anything.

    Constructors

    AchievementSyncAssetWriter(bool, Func<string, IReadOnlyList<string>>, Func<string, string, string, string, bool>, Func<string, string, string>, Func<string, string, string, string>, Func<string, string, string, bool, bool>, Func<string, string, bool>)

    Creates the writer.

    Declaration
    public AchievementSyncAssetWriter(bool previewOnly, Func<string, IReadOnlyList<string>> stringTableLocaleCodesProvider = null, Func<string, string, string, string, bool> stringTableEntryWriter = null, Func<string, string, string> stringTableWriteRefusalProvider = null, Func<string, string, string, string> stringTableEntryReader = null, Func<string, string, string, bool, bool> stringTableEntryRemover = null, Func<string, string, bool> stringTableSharedKeyProbe = null)
    Parameters
    Type Name Description
    bool previewOnly

    When true, every decision below still runs, but nothing is written.

    Func<string, IReadOnlyList<string>> stringTableLocaleCodesProvider

    Reads the locale codes of one string table collection. Defaults to Serenity.Global.Infrastructure.Editor.UnityLocalizationStringTableEditorUtils.GetLocaleCodesOf(System.String); injectable alongside stringTableEntryWriter so a test can fake a string table's existence and a write failure without needing a real Localization package reference in this assembly.

    Func<string, string, string, string, bool> stringTableEntryWriter

    Writes one localized entry — (collectionName, localeCode, key, value) → success. Defaults to Serenity.Global.Infrastructure.Editor.UnityLocalizationStringTableEditorUtils.TrySetStringTableEntry(System.String,System.String,System.String,System.String).

    Func<string, string, string> stringTableWriteRefusalProvider

    Says why one locale's table may not be written — (collectionName, localeCode) → the refusal sentence, or null when the write may proceed. Defaults to Serenity.Global.Infrastructure.Editor.UnityLocalizationStringTableEditorUtils.WriteRefusalFor(System.String,System.String), which refuses a table the Serenity package ships.

    Func<string, string, string, string> stringTableEntryReader

    Reads what one entry holds — (collectionName, localeCode, key) → its text, or null when the entry does not exist. Defaults to Serenity.Global.Infrastructure.Editor.UnityLocalizationStringTableEditorUtils.TryGetStringTableEntry(System.String,System.String,System.String,System.String@).

    Func<string, string, string, bool, bool> stringTableEntryRemover

    Removes one entry — (collectionName, localeCode, key, keepSharedKey) → success. Defaults to Serenity.Global.Infrastructure.Editor.UnityLocalizationStringTableEditorUtils.TryRemoveStringTableEntry(System.String,System.String,System.String,System.Boolean).

    Func<string, string, bool> stringTableSharedKeyProbe

    Says whether a collection's shared data already holds a key — (collectionName, key) → bool. Defaults to Serenity.Global.Infrastructure.Editor.UnityLocalizationStringTableEditorUtils.HasSharedKey(System.String,System.String).

    Properties

    PreviewOnly

    Declaration
    public bool PreviewOnly { get; }
    Property Value
    Type Description
    bool

    When true, this writer never mutates the project — see the type remarks.

    Methods

    Apply(AchievementSyncApplyRequest)

    Applies the accepted changes of one plan.

    Declaration
    public AchievementSyncApplyReport Apply(AchievementSyncApplyRequest request)
    Parameters
    Type Name Description
    AchievementSyncApplyRequest request

    What to apply and the context to apply it with.

    Returns
    Type Description
    AchievementSyncApplyReport

    What happened — or would have happened — for every item the plan carried.

    ProposeLocalId(string)

    Proposes a local id for a platform-only row from its api name, slugged the same way AchievementAuthoringRules requires an authored id to look. A caller-supplied proposal (ProposedLocalIdsByApiName) always wins; this is only the starting suggestion an author can edit before it is applied — an invalid one surfaces as a validation Error like any other bad id would.

    Declaration
    public static string ProposeLocalId(string apiName)
    Parameters
    Type Name Description
    string apiName

    The platform-side identity key to propose an id from.

    Returns
    Type Description
    string

    A slug proposal, or empty when apiName carries nothing to slug.

    In this article
    © 2026 Serenity. All Rights Reserved