Skip to content

Creating Asset Pipeline Plugins

Matthew LaRocca edited this page Nov 7, 2024 · 1 revision

The Asset Pipeline can be extended to support the processing of custom file formats via the creation of plugins.
This is facilitated by loading a manifest file describing the plugins to load when the pipeline is started.

Enabling Plugins

To load plugins, create a file pipeline/plugins.json in the root of your game's directory. Create a Javascript file for each plugin and reference it in the manifest file.

Plugin Manifest

The plugin manifest describes each plugin that will be loaded by the asset pipeline.
The src property describes the path to the Plugin class file and is specified relative to the manifest file. The extensions property is a list of file extensions that this plugin is associated with.

A minimal 'plugins.json` file:

{
    "version": 1,
    "plugins": [
        {
            "src": "ExamplePlugin.js",
            "extensions": [".myfile"]
        }
    ]
}

Plugin Class

A plugin is a class that must define an async process function. This is the main entrypoint the pipeline uses to hand off processing to your code. A minimal plugin class:

class ExamplePlugin {
    /** 
     * All plugin classes must define this method.  
     * It will be called by the asset pipeline when a file is encountered with the registered extension 
     * @param fileJson this is the json object for the particular file to be processed
     * @param environment this is the Environment object which contains relevant processing information
     * */
    async process(fileJson, environment) {
    }
}
module.exports = ExamplePlugin
Clone this wiki locally