Class AssetReplacementAnalysis
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
-
objectAssetReplacementAnalysis
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
sessionPackageSession
Returns
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
replacementsIEnumerable<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
rootPackagePackageselfPackagesIReadOnlySet<Package>loggerILoggerreplacementsList<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
Returns
- string
An error message, or null when the declaration is valid.