Vixen
02b45cc4
csharp
public sealed class ImportContext

Everything one import is allowed to read, and everything it has to declare.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Dependency registration is mandatory, and the context is what makes it enforceable. Files is a wrapper that refuses a read of anything not declared, so an importer that reaches for a sibling file without saying so fails at that moment instead of producing an artefact that is stale for ever. See UnregisteredReadException for why that trade is worth an exception.

The check is on by default rather than only in debug builds, which is a deviation from [08](../../docs/plan/08-asset-pipeline-and-addressables.md). An import runs at most once per asset per change and the check is a set lookup per file open, so it is not measurable; and an incrementality bug that only manifests in the configuration nobody develops in is the worst possible place for one.

Fields and properties (9)

  • public AssetId Guid

    The asset being imported.

  • public VirtualPath SourcePath

    Where its source file is.

  • public string Target

    Which build target this import is for — Windows, Android/Vulkan.

  • public IImportSettings Settings

    How this asset is configured, with per-target overrides already applied.

  • public string Importer

    Which importer is running, for messages.

  • public IFileProvider Files

    The only way to read a file. Refuses anything that was not declared first, unless the context was made without the check.

  • public IReadOnlyCollection<VirtualPath> FileDependencies

    Every file this import has declared it depends on, including the source.

  • public IReadOnlyCollection<AssetId> AssetDependencies

    Every other asset this import has declared it depends on.

  • public IReadOnlyList<ImportDiagnostic> Diagnostics

    Everything the importer has said so far.

Methods (8)

  • public ImportContext(AssetId guid, VirtualPath sourcePath, IImportSettings settings, IFileProvider files, string importer, string? target = null, bool enforceDeclaredReads = true)

    Sets up an import.

  • public void DependsOn(AssetId asset)

    Declares that this import's result depends on another asset.

  • public void DependsOnFile(VirtualPath path)

    Declares that this import's result depends on a file.

  • public ValueTask<Stream> OpenSourceAsync(CancellationToken cancellationToken = default(CancellationToken))

    Opens the asset's own source file.

  • public void Report(ImportSeverity severity, string message)

    Says something about the asset.

  • public SubAssetId DeclareSubAsset(string kind, string name)

    Declares a sub-asset and derives its stable id.

  • public void Write(SubAssetId subAsset, string type, ReadOnlyMemory<byte> content)

    Records an artefact the import produced.

  • public ImportResult Finish()

    Collects what the import produced.

Used by (49, showing 40)

  • AnimationClipImporterVixen.Editor.Assets
  • AnimationClipImporterTestsVixen.Editor.Assets.Tests
  • AssetImporterVixen.Editor.Assets
  • AssetReferenceScanVixen.Editor.Assets
  • AudioImporterVixen.Editor.Assets
  • AudioImporterTestsVixen.Editor.Assets.Tests
  • ClipMetadataTestsVixen.Editor.Assets.Tests
  • CompositorImporterVixen.Editor.Assets
  • ConstraintAuthoringImporterTestsVixen.Editor.Assets.Tests
  • ConstraintTemplateImporterVixen.Editor.Assets
  • CreateMenuTestsVixen.Editor.App.Tests
  • CubeLutImporterVixen.Editor.Assets
  • DeclaredReadsOnlyProviderVixen.Editor.Assets
  • FolderImporterVixen.Editor.Assets
  • HarnessPlanImporterVixen.Editor.Assets
  • HarnessPlanImporterTestsVixen.Editor.Assets.Tests
  • HeightmapImporterVixen.Editor.Assets
  • IAssetImporterVixen.Editor.Assets
  • ImportedGeometryLoadsTestsVixen.Editor.Assets.Tests
  • ImporterTestsVixen.Editor.Assets.Tests
  • InProcessImportExecutorVixen.Editor.Assets
  • MaterialImporterVixen.Editor.Assets
  • MaterialImporterTestsVixen.Editor.Assets.Tests
  • ModelImporterVixen.Editor.Assets
  • ModelImporterTestsVixen.Editor.Assets.Tests
  • MoveSetImporterVixen.Editor.Assets
  • MoveSetImporterTestsVixen.Editor.Assets.Tests
  • NativeFormatImporterVixen.Editor.Assets
  • NativeFormatImporterTestsVixen.Editor.Assets.Tests
  • NavMeshImporterVixen.Editor.Assets
  • NavMeshImporterTestsVixen.Editor.Assets.Tests
  • PaletteImporterVixen.Editor.Assets.Tests
  • PriorityLadderImporterVixen.Editor.Assets
  • ProxyShapeImporterTestsVixen.Editor.Assets.Tests
  • ProxyShapeSetImporterVixen.Editor.Assets
  • RawImporterVixen.Editor.Assets
  • RivalPaletteImporterVixen.Editor.Assets.Tests
  • RivalTextureImporterVixen.Editor.Assets.Tests
  • SceneImporterVixen.Editor.Assets
  • SceneImporterTestsVixen.Editor.Assets.Tests