> For the complete documentation index, see [llms.txt](https://docs.fullscreen.no/info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fullscreen.no/info/standalone-assets/runtime-studio/api/asset-import-processor-api.md).

# Asset Import Processor API

The Asset Importer plugin allows you to add support for your own runtime file formats.

Instead of replacing the entire import pipeline, you can register an **Asset Import Processor** that handles one or more file extensions while automatically integrating with Runtime Studio's existing import workflow.

Imported assets automatically benefit from:

* Import Review
* duplicate detection
* Project panel integration
* save and load
* export and import
* runtime asset libraries

### Overview

The primary extension point is:

`IAssetImportProcessor`

Create a processor when you want Runtime Studio to recognize and import your own file formats.

The built-in importers included with the Asset Importer plugin also use this processor system.

### How the Import Pipeline Works

When a file is imported, Runtime Studio performs the following steps:

1. Creates a `RuntimeAssetImportRequest`.
2. Searches all registered `IAssetImportProcessor` instances.
3. Calls `CanImport(...)` on each processor.
4. Uses the highest-priority processor that returns `true`.
5. Imports one or more `RuntimeImportedAsset` objects.
6. Displays the results in the Import Review window.
7. Imports the approved assets into the runtime Project panel.

This means custom processors automatically integrate with Runtime Studio's normal import workflow.

### Creating Your First Import Processor

A processor only requires three things:

* identify the file types it supports
* import the file
* return one or more `RuntimeImportedAsset` objects

Minimal example:

{% code overflow="wrap" expandable="true" %}

```cs
using System;
using System.Collections.Generic;
using System.Text;
using Fullscreen.RuntimeStudio.AssetImporter.Runtime;
using UnityEngine;

public sealed class MyTextImportProcessor : IAssetImportProcessor
{
    public string ProcessorId => "my-game.text.processor";
    public string ImporterId => "my-game.text";
    public int Priority => 100;

    public bool CanImport(RuntimeAssetImportRequest request)
    {
        return string.Equals(
            request?.Extension,
            "txt",
            StringComparison.OrdinalIgnoreCase);
    }

    public IEnumerable<RuntimeImportedAsset> Import(
        RuntimeAssetImportRequest request)
    {
        var textAsset = new TextAsset(
            Encoding.UTF8.GetString(request.Bytes));

        textAsset.name = request.NameWithoutExtension;
        textAsset.hideFlags = HideFlags.DontSave;

        yield return new RuntimeImportedAsset(
            Guid.NewGuid().ToString("N"),
            textAsset,
            textAsset.name,
            request.TargetFolder,
            ImporterId,
            request.FileName,
            request.Bytes,
            "text/plain");
    }
}
```

{% endcode %}

### Registering Your Processor

The recommended approach is through an `IEditorModule`.

{% code overflow="wrap" expandable="true" %}

```cs
public sealed class MyImportModule : IEditorModule
{
    public void Register(EditorModuleBuilder builder)
    {
        builder
            .AddDefaultAssetImportProcessor(
                new MyTextImportProcessor())
            .AddDefaultAssetImportFileType(
                new AssetImportFileType(
                    "my-game.text.files",
                    "Text Files",
                    "txt"));
    }
}
```

{% endcode %}

Registering an `AssetImportFileType` makes your format appear automatically in the Runtime Studio file picker and WebGL file browser.

Direct registry registration is also supported if required.

### Returning Multiple Assets

A single source file can produce multiple imported assets.

Common examples include:

* models
* materials
* textures
* animation clips
* meshes
* archive files

When importing multiple assets from the same source file:

* use a shared `sourceId`
* assign each imported asset a unique `resultId`

This allows Runtime Studio to correctly restore imported assets after loading a save.

### Working with Sidecar Files

Many formats reference additional files such as:

* `.mtl`
* textures
* binary payloads
* metadata files

These can be accessed from the import request.

{% code overflow="wrap" expandable="true" %}

```cs
if (request.TryGetSourceFile(
    "textures/albedo.png",
    out var file))
{
    // Use the companion file.
}
```

{% endcode %}

When distributing assets, packaging everything inside a `.zip` is generally the most reliable workflow.

### Useful Runtime Classes

The Asset Importer exposes several helper classes that can be useful when building custom importers.

#### RuntimeImportedAssetManager

Handles parsing and importing runtime assets.

Useful methods include:

* `TryImportBytes(...)`
* `TryImportRequest(...)`
* `AddImportedAssets(...)`

#### AssetImportProcessorRegistry

Registers and manages import processors.

#### AssetImportFileTypeRegistry

Registers file extensions that should appear in the Runtime Studio file picker.

#### RuntimeAssetImporterRegistry

Reports whether a file type is supported by the current importer pipeline.

### Processor IDs

Processors expose two identifiers.

#### ProcessorId

Identifies the processor registration.

Changing this only affects registration.

#### ImporterId

Identifies imported assets saved by your processor.

This value is written into Runtime Studio save data.

Once your importer has shipped, **do not change the `ImporterId`**, otherwise previously imported assets may no longer restore correctly.
