Skip to main content

Editor.RuntimeBundleExporter

Class

Lens Studio's built-in implementation of Editor.IRuntimeBundleExporter.

Lens Studio's built-in implementation of Editor.IRuntimeBundleExporter. Obtain it through pluginSystem.findInterface(Editor.IRuntimeBundleExporter) instead of constructing it.

Index

Example

RuntimeBundleExporter is the implementation returned for Editor.IRuntimeBundleExporter; use it through that interface. This example exports several assets without blocking the editor: each export runs on a background thread from a snapshot of the asset and shows its progress as a Lens Studio task.

export async function exportBundles(
pluginSystem: Editor.PluginSystem,
assets: Editor.Assets.Asset[],
targetDir: Editor.Path,
): Promise<Editor.Path[]> {
const exporter = pluginSystem.findInterface(Editor.IRuntimeBundleExporter) as Editor.IRuntimeBundleExporter;
const exported: Editor.Path[] = [];
for (const asset of assets) {
// Each bundle is named after its asset, so give the assets distinct names.
const path: Editor.Path | undefined = await exporter.exportRuntimeBundleAsync(asset, targetDir);
if (!path || path.isEmpty) {
throw new Error(`Could not export "${asset.name}" as a runtime bundle`);
}
exported.push(path);
}
console.log(`Exported ${exported.length} runtime bundle(s) to ${targetDir.toString()}`);
return exported;
}

Extends

Properties

interfaceId

static interfaceId: InterfaceId

Static interface ID for resolving the runtime bundle exporter via the plugin system.

Inherited from

IRuntimeBundleExporter.interfaceId

Methods

exportRuntimeBundle()

exportRuntimeBundle(asset, targetDir): Path

Export the asset and the assets it references as a zipped runtime bundle in targetDir, in a file named after the asset. Only asset types that can be converted for the runtime are supported, such as object prefabs and textures; for any other type an "Unsupported converter" warning is logged. Returns the path of the created file, or undefined if the export fails.

Parameters

ParameterType
assetAsset
targetDirPath

Returns

Path

Inherited from

IRuntimeBundleExporter.exportRuntimeBundle


exportRuntimeBundleAsync()

exportRuntimeBundleAsync(asset, targetDir): any

Export the asset as a runtime bundle on a background thread, working from a snapshot of the asset. Supports the same asset types as exportRuntimeBundle. Returns a promise that resolves to the created file path, or undefined if the export fails.

Parameters

ParameterType
assetAsset
targetDirPath

Returns

any

Inherited from

IRuntimeBundleExporter.exportRuntimeBundleAsync


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

IRuntimeBundleExporter.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

IRuntimeBundleExporter.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

IRuntimeBundleExporter.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

IRuntimeBundleExporter.isSame