Editor.IContext
ClassEditor context passed to context action callbacks when a right-click menu is triggered.
Index
Methods
Example
// IContext is the abstract base passed to every context-menu action callback.
// Concrete subclasses: AssetContext (right-click in asset browser)
// and ObjectContext (right-click a scene object). Use isOfType()
// to branch on the actual context at call time.
const registry = this.pluginSystem.findInterface(
Editor.IContextActionRegistry.interfaceId
) as Editor.IContextActionRegistry;
const guard = registry.registerAction((ctx: Editor.IContext) => {
if (ctx.isOfType('Editor.Model.AssetContext')) {
const assetCtx = ctx as Editor.Model.AssetContext;
console.log(`AssetContext: ${assetCtx.selection.length} asset(s) selected`);
} else if (ctx.isOfType('Editor.Model.ObjectContext')) {
const objCtx = ctx as Editor.Model.ObjectContext;
console.log(`ObjectContext: ${objCtx.selection.length} object(s) selected`);
}
return undefined as unknown as Editor;
});
this.guards.push(guard);
Extends
Extended by
Methods
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