UNPKG

unity-editor-mcp

Version:

MCP server for Unity Editor integration - enables AI assistants to control Unity Editor

52 lines (47 loc) 1.64 kB
import { BaseToolHandler } from '../base/BaseToolHandler.js'; export class GetUIElementStateToolHandler extends BaseToolHandler { constructor(unityConnection) { super( 'get_ui_element_state', 'Get detailed state information about UI elements', { type: 'object', properties: { elementPath: { type: 'string', description: 'Full hierarchy path to the UI element' }, includeChildren: { type: 'boolean', default: false, description: 'Include child element states' }, includeInteractableInfo: { type: 'boolean', default: true, description: 'Include interaction capabilities' } }, required: ['elementPath'] } ); this.unityConnection = unityConnection; } async execute(params) { const { elementPath, includeChildren = false, includeInteractableInfo = true } = params; // Ensure connected if (!this.unityConnection.isConnected()) { await this.unityConnection.connect(); } const result = await this.unityConnection.sendCommand('get_ui_element_state', { elementPath, includeChildren, includeInteractableInfo }); return result; } }