Editor.PluginSystem
ClassProvides access to the Lens Studio editor plugins, components, and interfaces
Index
Properties
Methods
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
readonlydescriptors: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
| Parameter | Type |
|---|---|
descriptor | IPluginDescriptor |
Returns
findInterface()
findInterface(
id):IInterface
Get various interfaces to the Lens Studio editor, such as its Editor.Model and Editor.Model.AssetManager.
Parameters
| Parameter | Type |
|---|---|
id | any |
Returns
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
Inherited from
loadDirectory()
loadDirectory(
directory):void
Loads all plugins found in the specified directory path.
Parameters
| Parameter | Type |
|---|---|
directory | Path |
Returns
void
unloadDirectory()
unloadDirectory(
directory):void
Unloads all plugins previously loaded from the specified directory path.
Parameters
| Parameter | Type |
|---|---|
directory | Path |
Returns
void