Skip to main content

LensStudio:EditorPlugin

Module

Module providing base classes for building editor plugins that integrate custom editing behavior into Lens Studio.

Example

// EditorPlugin is the base class for plugins that provide custom inspectors
// for specific entity types in the Inspector panel.
//
// Pattern:
// 1. Extend EditorPlugin
// 2. In descriptor(), set canEdit callback to filter entities
// 3. Override createWidget(parent) to build the inspector UI
// 4. Override edit(entities) to populate UI with entity data
// 5. Override deinit() for cleanup

export class EditorPluginExampleEditor extends EditorPlugin {
connections: any[];
root: Widget | null;
label: Label | null;
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.EditorPluginExample';
d.name = 'EditorPlugin Overview';
d.description = 'Demonstrates a minimal EditorPlugin for SceneObjects';
d.canEdit = (entity: Editor.Model.Entity) => {
return !Editor.isNull(entity) && entity.isOfType('SceneObject');
};
return d;
}
constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
super(pluginSystem, descriptor);
this.connections = [];
this.root = null;
this.label = null;
}
createWidget(parent: Widget): Widget {
this.root = new Widget(parent);
const layout = new BoxLayout();
layout.setDirection(Direction.TopToBottom);
this.root.layout = layout;

this.label = new Label(this.root);
this.label.text = 'Select a SceneObject to inspect';
this.label.wordWrap = true;
layout.addWidget(this.label);

return this.root;
}
edit(entities: Editor.Model.Entity[]): boolean {
const obj = entities.find(
(e: Editor.Model.Entity) => !Editor.isNull(e) && e.isOfType('SceneObject')
) as unknown as Editor.Model.SceneObject | undefined;
if (obj && this.label) {
this.label.text = `Editing: ${obj.name}`;
}
return true;
}
deinit(): void {
this.connections.forEach((c: any) => c?.disconnect());
this.connections = [];
if (this.root) { this.root.deleteLater(); this.root = null; }
this.label = null;
}
}

Classes

ClassDescription
DescriptorDescriptor for an editor plugin, extending EditorDescriptor with a canEdit predicate to determine which entities the plugin handles.
EditorPluginBase class for editor plugins, constructed with a PluginSystem and optional Descriptor to integrate custom editing logic.