Editor.IRuntimeBundleExporter
ClassInterface for exporting an asset, together with the assets it references, as a runtime bundle file.
Interface for exporting an asset, together with the assets it references, as a runtime bundle file. Resolve it through pluginSystem.findInterface().
Index
Example
Export an asset as a runtime bundle to a file path the user chose, such as Hat.prfb. exportRuntimeBundle names its output after the asset, so export into a temporary directory and copy the result. Requires the plugin's filesystem permission.
import { copyFile, exists, remove, TempDir } from 'LensStudio:FileSystem';
export function exportBundleToFile(
pluginSystem: Editor.PluginSystem,
asset: Editor.Assets.Asset,
destination: Editor.Path,
): Editor.Path {
const exporter = pluginSystem.findInterface(Editor.IRuntimeBundleExporter) as Editor.IRuntimeBundleExporter;
const tempDir = TempDir.create();
const exported = exporter.exportRuntimeBundle(asset, tempDir.path);
if (!exported || exported.isEmpty) {
throw new Error(`Could not export "${asset.name}" as a runtime bundle`);
}
if (exists(destination)) remove(destination);
copyFile(exported, destination);
console.log(`Exported "${asset.name}" to ${destination.toString()}`);
return destination;
}
Extends
Extended by
Properties
interfaceId
staticinterfaceId:InterfaceId
Static interface ID for resolving the runtime bundle exporter via the plugin system.
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
Returns
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
Returns
any
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean