Skip to content

Class AssetImporter

Namespace: Apogee.Content.Import
Assembly: Apogee.Content.dll

Turns the assets of a game into the engine's own formats. It is a small registry: each takes some extensions (models, images, shaders…) and writes an artifact for each asset, in res://imported/ beside an index.xml that says which source each came from ( reads it). Artifacts are kept: an asset is imported again only when its key changes, the SHA-256 of the importer's name and fingerprint, the asset's .import.xml settings, the asset, and every file the import read for it (a model's buffers and textures, the modules a shader imports). Artifacts whose source is gone are deleted. Importers run in the order of the list, and a file that an earlier import read (a model's image) is not imported on its own. res:// has to be writable.

Importing also gives assets their UID (): an imported file gets one in its .import.xml (made if there is none), an authored one () in its root, and imported/assets.xml lists them all for . The UID is not part of the key (), so minting one never imports anything again. A UID that is already there is never changed, except to tell a copy from its original.

public sealed class AssetImporter

Inheritance

object ← AssetImporter

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Constructors

AssetImporter(VirtualFileSystem, IReadOnlyList<IAssetImporter>?)

Turns the assets of a game into the engine's own formats. It is a small registry: each takes some extensions (models, images, shaders…) and writes an artifact for each asset, in res://imported/ beside an index.xml that says which source each came from ( reads it). Artifacts are kept: an asset is imported again only when its key changes, the SHA-256 of the importer's name and fingerprint, the asset's .import.xml settings, the asset, and every file the import read for it (a model's buffers and textures, the modules a shader imports). Artifacts whose source is gone are deleted. Importers run in the order of the list, and a file that an earlier import read (a model's image) is not imported on its own. res:// has to be writable.

Importing also gives assets their UID (): an imported file gets one in its .import.xml (made if there is none), an authored one () in its root, and imported/assets.xml lists them all for . The UID is not part of the key (), so minting one never imports anything again. A UID that is already there is never changed, except to tell a copy from its original.

public AssetImporter(VirtualFileSystem files, IReadOnlyList<IAssetImporter>? importers = null)

Parameters

files VirtualFileSystem

importers IReadOnlyList<IAssetImporter>?

Fields

CacheFolder

public const string CacheFolder = "imported"

Field Value

string

ImporterVersion

Bumped when the key or the index changes, so that old artifacts are made again.

public const int ImporterVersion = 3

Field Value

int

Properties

Defaults

The importers of the content library: models, then images.

public static IReadOnlyList<IAssetImporter> Defaults { get; }

Property Value

IReadOnlyList<IAssetImporter>

Methods

LoadIndex(VirtualFileSystem)

What the index in files says has been imported (empty when there is none).

public static IReadOnlyList<ImportEntry> LoadIndex(VirtualFileSystem files)

Parameters

files VirtualFileSystem

Returns

IReadOnlyList<ImportEntry>

Reimport(string)

Imports one asset again whether or not it changed, and leaves the rest of the index as it is. A file no importer takes is reported as failed.

public ImportReport Reimport(string source)

Parameters

source string

Returns

ImportReport

Run(bool)

Imports what needs it. force imports everything again.

public ImportReport Run(bool force = false)

Parameters

force bool

Returns

ImportReport

StatusOf(string)

Where the asset source (relative to res://: models/car.glb) stands, from the index and the file as it is now. It reads the files, so it is for a person looking at one, not for every file every frame.

public AssetStatus StatusOf(string source)

Parameters

source string

Returns

AssetStatus