Skip to main content

Editor.PluginSystem

Class

Provides access to the Lens Studio editor plugins, components, and interfaces

Index

Example

import { Preset } from 'LensStudio:Preset';

export class ObjectPrefabPreset extends Preset {
static descriptor() {
return {
id: 'Com.Snap.ObjectPrefabPreset',
interfaces: Preset.descriptor().interfaces,
dependencies: [Editor.Model.IModel],
name: 'Object Prefab',
description: '',
icon: Editor.Icon.fromFile(import.meta.resolve('../Resources/ObjectPrefab.svg')),
section: 'General',
entityType: 'ObjectPrefab'
};
}
constructor(pluginSystem) {
super(pluginSystem);
}
create(destination) {
const model = this.pluginSystem.findInterface(Editor.Model.IModel);
const assetManager = model.project.assetManager;

const prefab = assetManager.createNativeAsset('ObjectPrefab', 'ObjectPrefab', destination);

const object = prefab.addSceneObject(null);
object.name = 'Object Prefab';

return prefab;
}
}
// Triggering another plugin from a plugin
import { MyOtherPluginPreset } from './MyOtherPluginPreset.js';
const myOtherPluginPreset = new MyOtherPluginPreset(this.pluginSystem);
myOtherPluginResult = await myOtherPluginPreset.createAsync();

Extends

Properties

descriptors

readonly descriptors: IPluginDescriptor[]

Read-only list of all currently registered plugin descriptors.

Methods

create()

create(descriptor): IPlugin

Instantiates a plugin from the given descriptor and returns it as an IPlugin.

Parameters

ParameterType
descriptorIPluginDescriptor

Returns

IPlugin


findInterface()

findInterface(id): IInterface

Get various interfaces to the Lens Studio editor, such as its Editor.Model and Editor.Model.AssetManager.

Parameters

ParameterType
idany

Returns

IInterface


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.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

ScriptObject.isSame


loadDirectory()

loadDirectory(directory): void

Loads all plugins found in the specified directory path.

Parameters

ParameterType
directoryPath

Returns

void


unloadDirectory()

unloadDirectory(directory): void

Unloads all plugins previously loaded from the specified directory path.

Parameters

ParameterType
directoryPath

Returns

void