Preparing search index...

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

    // 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;
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    id: string
    pluginSystem: PluginSystem

    The plugin system instance this plugin belongs to.

    Methods

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

      Parameters

      Returns Widget

    • Cleans up and deinitializes the plugin.

      Returns void

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

      Parameters

      Returns boolean

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object refers to the same instance as the given object.

      Parameters

      Returns boolean