Skip to main content

Editor.Model.AssetContext

Class

Context object holding the current asset selection, providing access to selected assets and their paths.

Index

Example

// AssetContext is the IContext subclass handed to right-click callbacks
// triggered from the asset browser. Its `selection` is an array of
// AssetContext.Item — each Item exposes `asset` and `path`.
const registry = this.pluginSystem.findInterface(
Editor.IContextActionRegistry.interfaceId
) as Editor.IContextActionRegistry;

const guard = registry.registerAction((ctx: Editor.IContext) => {
if (!ctx.isOfType('Editor.Model.AssetContext')) {
return undefined as unknown as Editor;
}
const assetCtx = ctx as Editor.Model.AssetContext;
for (const item of assetCtx.selection) {
console.log(`Selected asset: ${item.asset.name} at ${item.path.toString()}`);
}
return undefined as unknown as Editor;
});
this.guards.push(guard);

Extends

Properties

isDetailedView

readonly isDetailedView: boolean

Whether the asset panel is currently rendering the detailed (list) view rather than the icon view.


selection

readonly selection: Item[]

Read-only array of currently selected asset items in the asset panel.

Methods

getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

IContext.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

IContext.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

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

IContext.isSame

Nested types

Classes

ClassDescription
ItemRepresents a single selected asset entry, pairing an asset reference with its file path.