Skip to main content

LensStudio:EditorPlugin.EditorPlugin

Class

Base class for editor plugins, constructed with a PluginSystem and optional Descriptor to integrate custom editing logic.

Index

Example

// EditorPlugin provides custom Inspector panels for specific entity types.
//
// Lifecycle:
// 1. canEdit(entity) from Descriptor is evaluated per selected entity
// 2. createWidget(parent) builds the UI widget tree (called once)
// 3. edit(entities) populates UI with the selected entities
// 4. deinit() cleans up when selection changes away
//
// Unlike DialogPlugin (user-triggered), EditorPlugin is selection-driven.

export class EditorPluginEditorPluginExampleEditor extends EditorPlugin {
connections: any[];
root: Widget | null;
infoLabel: Label | null;
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.EditorPluginEditorPluginExample';
d.name = 'EditorPlugin Class Example';
d.description = 'Demonstrates EditorPlugin lifecycle with edit()';
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.infoLabel = null;
}
createWidget(parent: Widget): Widget {
this.root = new Widget(parent);
const layout = new BoxLayout();
layout.setDirection(Direction.TopToBottom);
layout.spacing = 8;
this.root.layout = layout;

this.infoLabel = new Label(this.root);
this.infoLabel.text = 'Waiting for selection...';
this.infoLabel.wordWrap = true;
layout.addWidget(this.infoLabel);

return this.root;
}
edit(entities: Editor.Model.Entity[]): boolean {
const sceneObjs = entities.filter(
(e: Editor.Model.Entity) => !Editor.isNull(e) && e.isOfType('SceneObject')
);
if (this.infoLabel && sceneObjs.length > 0) {
const names = sceneObjs.map(
(e: Editor.Model.Entity) => (e as unknown as Editor.Model.SceneObject).name
);
this.infoLabel.text = `Editing ${names.length} object(s): ${names.join(', ')}`;
}
return true;
}
deinit(): void {
this.connections.forEach((c: any) => c?.disconnect());
this.connections = [];
if (this.root) { this.root.deleteLater(); this.root = null; }
this.infoLabel = null;
}
}

Extends

Constructors

Constructor

new EditorPlugin(pluginSystem, descriptor?): EditorPlugin

Constructs an EditorPlugin instance, optionally bound to a plugin system and descriptor.

Parameters

ParameterType
pluginSystemPluginSystem
descriptor?Descriptor

Returns

EditorPlugin

Overrides

Editor.IPlugin.constructor

Properties

id

readonly id: string

Unique string identifier of the plugin instance.

Inherited from

IPlugin.id


pluginSystem

readonly pluginSystem: PluginSystem

The plugin system instance this plugin belongs to.

Methods

createWidget()

createWidget(parent): Widget

Creates and returns a widget parented to the given parent widget.

Parameters

ParameterType
parentWidget

Returns

Widget


deinit()

deinit(): void

Cleans up and deinitializes the plugin.

Returns

void


edit()

edit(entities): boolean

Handles editing of the given entities, returning true if the plugin handled them.

Parameters

ParameterType
entitiesEntity[]

Returns

boolean


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

IPlugin.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

IPlugin.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

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

IPlugin.isSame


setTitle()

setTitle(subtitle): void

Parameters

ParameterType
subtitlestring

Returns

void