Table of Contents

Class AssetReplacementAnalysis

Namespace
Stride.Core.Assets.Analysis
Assembly
Stride.Core.Assets.dll

Build-time support for Replaces: validates the declarations visible from the root package, then substitutes each replaced asset's content in the build session so both compile-time baking and the compiled content index resolve to the replacement.

public static class AssetReplacementAnalysis
Inheritance
object
AssetReplacementAnalysis

Methods

CollectSessionReplacements(PackageSession?)

Collects the session's replacement declarations without validation, keyed by replaced URL (first declaration wins). For editor use, where problems surface as diagnostics instead of errors.

public static Dictionary<string, AssetItem>? CollectSessionReplacements(PackageSession? session)

Parameters

session PackageSession

Returns

Dictionary<string, AssetItem>

Substitute(IEnumerable<AssetReplacement>)

Swaps each replaced asset's content for a clone of its replacement, keeping the replaced asset's identity (id and location) so id- and URL-based resolution — including compile-time content baking — use the replacement. For build sessions only (the swap is never saved).

public static void Substitute(IEnumerable<AssetReplacement> replacements)

Parameters

replacements IEnumerable<AssetReplacement>

TryCollect(Package, IReadOnlySet<Package>, ILogger, out List<AssetReplacement>)

Collects and validates the replacement declarations of rootPackage and its dependencies. When two packages replace the same URL, a declaration from selfPackages (the built game's own packages) wins over a dependency's; other conflicts, missing targets and incompatible asset types are errors.

public static bool TryCollect(Package rootPackage, IReadOnlySet<Package> selfPackages, ILogger logger, out List<AssetReplacement> replacements)

Parameters

rootPackage Package
selfPackages IReadOnlySet<Package>
logger ILogger
replacements List<AssetReplacement>

Returns

bool

false when any declaration is invalid (errors are logged).

ValidateDeclaration(AssetItem, AssetItem?)

Validates a single replacement declaration against its resolved target.

public static string? ValidateDeclaration(AssetItem replacer, AssetItem? target)

Parameters

replacer AssetItem
target AssetItem

Returns

string

An error message, or null when the declaration is valid.