@akiojin/unity-mcp-server 3.2.1 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/config.js +27 -0
- package/src/core/projectInfo.js +17 -2
- package/src/core/toolManifest.json +79 -79
- package/src/core/unityConnection.js +74 -7
- package/src/handlers/analysis/FindByComponentToolHandler.js +1 -1
- package/src/handlers/analysis/GetComponentValuesToolHandler.js +1 -1
- package/src/handlers/analysis/GetObjectReferencesToolHandler.js +1 -1
- package/src/handlers/asset/AssetDatabaseManageToolHandler.js +1 -1
- package/src/handlers/asset/AssetDependencyAnalyzeToolHandler.js +1 -1
- package/src/handlers/asset/AssetImportSettingsManageToolHandler.js +1 -1
- package/src/handlers/asset/AssetMaterialCreateToolHandler.js +1 -1
- package/src/handlers/asset/AssetMaterialModifyToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabCreateToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabExitModeToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabInstantiateToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabModifyToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabOpenToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabSaveToolHandler.js +1 -1
- package/src/handlers/compilation/CompilationGetStateToolHandler.js +1 -1
- package/src/handlers/component/ComponentAddToolHandler.js +1 -1
- package/src/handlers/component/ComponentFieldSetToolHandler.js +1 -1
- package/src/handlers/component/ComponentGetTypesToolHandler.js +1 -1
- package/src/handlers/component/ComponentListToolHandler.js +1 -1
- package/src/handlers/component/ComponentModifyToolHandler.js +1 -1
- package/src/handlers/component/ComponentRemoveToolHandler.js +1 -1
- package/src/handlers/console/ConsoleClearToolHandler.js +1 -1
- package/src/handlers/console/ConsoleReadToolHandler.js +1 -1
- package/src/handlers/editor/EditorLayersManageToolHandler.js +21 -25
- package/src/handlers/editor/EditorQuitToolHandler.js +1 -1
- package/src/handlers/editor/EditorSelectionManageToolHandler.js +1 -1
- package/src/handlers/editor/EditorTagsManageToolHandler.js +1 -1
- package/src/handlers/editor/EditorToolsManageToolHandler.js +1 -1
- package/src/handlers/editor/EditorWindowsManageToolHandler.js +1 -1
- package/src/handlers/gameobject/GameObjectCreateToolHandler.js +2 -2
- package/src/handlers/gameobject/GameObjectDeleteToolHandler.js +2 -2
- package/src/handlers/gameobject/GameObjectFindToolHandler.js +19 -5
- package/src/handlers/gameobject/GameObjectGetHierarchyToolHandler.js +2 -2
- package/src/handlers/gameobject/GameObjectModifyToolHandler.js +2 -2
- package/src/handlers/menu/MenuItemExecuteToolHandler.js +1 -1
- package/src/handlers/package/PackageManagerToolHandler.js +2 -2
- package/src/handlers/package/RegistryConfigToolHandler.js +1 -1
- package/src/handlers/playmode/PlaymodeGetStateToolHandler.js +1 -1
- package/src/handlers/playmode/PlaymodePauseToolHandler.js +2 -2
- package/src/handlers/playmode/PlaymodePlayToolHandler.js +2 -2
- package/src/handlers/playmode/PlaymodeStopToolHandler.js +2 -2
- package/src/handlers/playmode/PlaymodeWaitForStateToolHandler.js +1 -1
- package/src/handlers/scene/SceneCreateToolHandler.js +1 -1
- package/src/handlers/scene/SceneListToolHandler.js +1 -1
- package/src/handlers/scene/SceneLoadToolHandler.js +1 -1
- package/src/handlers/scene/SceneSaveToolHandler.js +1 -1
- package/src/handlers/screenshot/ScreenshotAnalyzeToolHandler.js +1 -1
- package/src/handlers/screenshot/ScreenshotCaptureToolHandler.js +1 -1
- package/src/handlers/script/ScriptSymbolsGetToolHandler.js +39 -21
- package/src/handlers/settings/SettingsGetToolHandler.js +1 -1
- package/src/handlers/settings/SettingsUpdateToolHandler.js +1 -1
- package/src/handlers/system/SystemGetCommandStatsToolHandler.js +1 -1
- package/src/handlers/system/SystemPingToolHandler.js +2 -2
- package/src/handlers/system/SystemRefreshAssetsToolHandler.js +2 -2
- package/src/handlers/test/TestGetStatusToolHandler.js +1 -1
- package/src/handlers/test/TestRunToolHandler.js +1 -1
- package/src/handlers/ui/UIClickElementToolHandler.js +1 -1
- package/src/handlers/ui/UIFindElementsToolHandler.js +1 -1
- package/src/handlers/ui/UIGetElementStateToolHandler.js +1 -1
- package/src/handlers/ui/UISetElementValueToolHandler.js +1 -1
- package/src/handlers/ui/UISimulateInputToolHandler.js +1 -1
- package/src/handlers/video/VideoCaptureForToolHandler.js +6 -6
- package/src/handlers/video/VideoCaptureStartToolHandler.js +1 -1
- package/src/handlers/video/VideoCaptureStatusToolHandler.js +1 -1
- package/src/handlers/video/VideoCaptureStopToolHandler.js +2 -2
- package/src/tools/analysis/analyzeSceneContents.js +2 -2
- package/src/tools/analysis/findByComponent.js +2 -2
- package/src/tools/analysis/getAnimatorState.js +6 -6
- package/src/tools/analysis/getComponentValues.js +2 -2
- package/src/tools/analysis/getGameObjectDetails.js +2 -2
- package/src/tools/analysis/getInputActionsState.js +2 -2
- package/src/tools/analysis/getObjectReferences.js +2 -2
- package/src/tools/input/inputActionsEditor.js +9 -9
- package/src/tools/scene/createScene.js +3 -3
- package/src/tools/scene/getSceneInfo.js +2 -2
- package/src/tools/scene/listScenes.js +3 -3
- package/src/tools/scene/loadScene.js +3 -3
- package/src/tools/scene/saveScene.js +3 -3
- package/src/tools/system/ping.js +5 -5
- package/src/core/unityCommandType.js +0 -10
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Handler for the
|
|
4
|
+
* Handler for the pause_game tool
|
|
5
5
|
*/
|
|
6
6
|
export class PlaymodePauseToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
|
-
super('
|
|
8
|
+
super('pause_game', 'Pause or resume Unity play mode', {
|
|
9
9
|
type: 'object',
|
|
10
10
|
properties: {},
|
|
11
11
|
required: []
|
|
@@ -2,11 +2,11 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
2
2
|
import { extractEditorState } from '../../utils/editorState.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Handler for the
|
|
5
|
+
* Handler for the play_game tool
|
|
6
6
|
*/
|
|
7
7
|
export class PlaymodePlayToolHandler extends BaseToolHandler {
|
|
8
8
|
constructor(unityConnection) {
|
|
9
|
-
super('
|
|
9
|
+
super('play_game', 'Enter Play Mode.', {
|
|
10
10
|
type: 'object',
|
|
11
11
|
properties: {},
|
|
12
12
|
required: []
|
|
@@ -2,11 +2,11 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
2
2
|
import { extractEditorState } from '../../utils/editorState.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Handler for the
|
|
5
|
+
* Handler for the stop_game tool
|
|
6
6
|
*/
|
|
7
7
|
export class PlaymodeStopToolHandler extends BaseToolHandler {
|
|
8
8
|
constructor(unityConnection) {
|
|
9
|
-
super('
|
|
9
|
+
super('stop_game', 'Exit Play Mode and return to Edit Mode.', {
|
|
10
10
|
type: 'object',
|
|
11
11
|
properties: {},
|
|
12
12
|
required: []
|
|
@@ -31,7 +31,7 @@ export class PlaymodeWaitForStateToolHandler extends BaseToolHandler {
|
|
|
31
31
|
} catch {}
|
|
32
32
|
}
|
|
33
33
|
try {
|
|
34
|
-
const state = await this.unityConnection.sendCommand('
|
|
34
|
+
const state = await this.unityConnection.sendCommand('get_editor_state', {});
|
|
35
35
|
if (!!state?.isPlaying === want) {
|
|
36
36
|
return { status: 'success', state, waitedMs: Date.now() - start };
|
|
37
37
|
}
|
|
@@ -5,7 +5,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export class SceneCreateToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
|
-
super('
|
|
8
|
+
super('create_scene', 'Create a new scene (optionally load it and add to build settings).', {
|
|
9
9
|
type: 'object',
|
|
10
10
|
properties: {
|
|
11
11
|
sceneName: {
|
|
@@ -5,7 +5,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export class SceneListToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
|
-
super('
|
|
8
|
+
super('list_scenes', 'List scenes in project (filter to loaded/build scenes or by path).', {
|
|
9
9
|
type: 'object',
|
|
10
10
|
properties: {
|
|
11
11
|
includeLoadedOnly: {
|
|
@@ -5,7 +5,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export class SceneLoadToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
|
-
super('
|
|
8
|
+
super('load_scene', 'Load a scene by path or name (Single/Additive).', {
|
|
9
9
|
type: 'object',
|
|
10
10
|
properties: {
|
|
11
11
|
scenePath: {
|
|
@@ -5,7 +5,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export class SceneSaveToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
|
-
super('
|
|
8
|
+
super('save_scene', 'Save current scene or save as a specified path.', {
|
|
9
9
|
type: 'object',
|
|
10
10
|
properties: {
|
|
11
11
|
scenePath: {
|
|
@@ -7,7 +7,7 @@ import path from 'path';
|
|
|
7
7
|
export class ScreenshotAnalyzeToolHandler extends BaseToolHandler {
|
|
8
8
|
constructor(unityConnection) {
|
|
9
9
|
super(
|
|
10
|
-
'
|
|
10
|
+
'analyze_screenshot',
|
|
11
11
|
'Analyze a screenshot: dimensions/colors, UI elements, and scene content (basic/ui/content/full). For LLMs, prefer basic/ui; use full only when necessary. Provide either imagePath (preferred) or base64 (not both).',
|
|
12
12
|
{
|
|
13
13
|
type: 'object',
|
|
@@ -6,7 +6,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
6
6
|
export class ScreenshotCaptureToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
8
|
super(
|
|
9
|
-
'
|
|
9
|
+
'capture_screenshot',
|
|
10
10
|
'Capture Game/Scene/Window/Explorer screenshots. Output path is fixed to <workspace>/.unity/capture/. For LLM use, prefer explorer mode (auto-framing, clarity). Use encodeAsBase64=true only for immediate analysis, and keep resolution minimal.',
|
|
11
11
|
{
|
|
12
12
|
type: 'object',
|
|
@@ -3,6 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
4
4
|
import { ProjectInfoProvider } from '../../core/projectInfo.js';
|
|
5
5
|
import { LspRpcClientSingleton } from '../../lsp/LspRpcClientSingleton.js';
|
|
6
|
+
import { parseFileSymbols } from '../../utils/csharpParse.js';
|
|
6
7
|
|
|
7
8
|
export class ScriptSymbolsGetToolHandler extends BaseToolHandler {
|
|
8
9
|
constructor(unityConnection) {
|
|
@@ -63,28 +64,45 @@ export class ScriptSymbolsGetToolHandler extends BaseToolHandler {
|
|
|
63
64
|
hint: `Verify the file exists at: ${abs}. Path must be relative to Unity project root (e.g., "Assets/Scripts/Foo.cs" or "Packages/com.example/Runtime/Bar.cs").`
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
67
|
+
try {
|
|
68
|
+
const lsp = await LspRpcClientSingleton.getInstance(info.projectRoot);
|
|
69
|
+
const uri = 'file://' + abs.replace(/\\\\/g, '/');
|
|
70
|
+
const res = await lsp.request('textDocument/documentSymbol', { textDocument: { uri } });
|
|
71
|
+
const docSymbols = res?.result ?? res ?? [];
|
|
72
|
+
const list = [];
|
|
73
|
+
const visit = (s, container) => {
|
|
74
|
+
const start = s.range?.start || s.selectionRange?.start || {};
|
|
75
|
+
// Phase 3.3: Optimized output (50% size reduction)
|
|
76
|
+
// Removed redundant endLine/endColumn, renamed to line/column
|
|
77
|
+
const sym = {
|
|
78
|
+
name: s.name || '',
|
|
79
|
+
kind: this.mapKind(s.kind),
|
|
80
|
+
line: (start.line ?? 0) + 1,
|
|
81
|
+
column: (start.character ?? 0) + 1
|
|
82
|
+
};
|
|
83
|
+
// Only include non-null optional fields
|
|
84
|
+
if (container) sym.container = container;
|
|
85
|
+
list.push(sym);
|
|
86
|
+
if (Array.isArray(s.children)) for (const c of s.children) visit(c, s.name || container);
|
|
80
87
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
if (Array.isArray(docSymbols)) for (const s of docSymbols) visit(s, null);
|
|
89
|
+
return { success: true, path: relPath, symbols: list };
|
|
90
|
+
} catch (e) {
|
|
91
|
+
// Fallback: lightweight regex-based symbol extraction (no Roslyn)
|
|
92
|
+
const text = await fs.readFile(abs, 'utf8');
|
|
93
|
+
const parsed = parseFileSymbols(relPath, text);
|
|
94
|
+
const list = (parsed.symbols || []).map(s => {
|
|
95
|
+
const sym = {
|
|
96
|
+
name: s.name || '',
|
|
97
|
+
kind: s.kind,
|
|
98
|
+
line: s.startLine,
|
|
99
|
+
column: s.startColumn
|
|
100
|
+
};
|
|
101
|
+
if (s.container) sym.container = s.container;
|
|
102
|
+
return sym;
|
|
103
|
+
});
|
|
104
|
+
return { success: true, path: relPath, symbols: list, warning: 'csharp-lsp unavailable' };
|
|
105
|
+
}
|
|
88
106
|
} catch (e) {
|
|
89
107
|
return { error: e.message || 'Failed to get symbols' };
|
|
90
108
|
}
|
|
@@ -6,7 +6,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
6
6
|
export class SettingsGetToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
8
|
super(
|
|
9
|
-
'
|
|
9
|
+
'get_project_settings',
|
|
10
10
|
'Get project settings by category via include flags (player/graphics/quality/physics/etc.).',
|
|
11
11
|
{
|
|
12
12
|
type: 'object',
|
|
@@ -6,7 +6,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
6
6
|
export class SettingsUpdateToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
8
|
super(
|
|
9
|
-
'
|
|
9
|
+
'update_project_settings',
|
|
10
10
|
'Update project settings by category with a confirmation safety flag.',
|
|
11
11
|
{
|
|
12
12
|
type: 'object',
|
|
@@ -3,7 +3,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
3
3
|
export class SystemGetCommandStatsToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
5
|
super(
|
|
6
|
-
'
|
|
6
|
+
'get_command_stats',
|
|
7
7
|
'Retrieve aggregated counts and recent Unity command types to audit traffic.',
|
|
8
8
|
{
|
|
9
9
|
type: 'object',
|
|
@@ -3,13 +3,13 @@ import { CATEGORIES, SCOPES } from '../base/categories.js';
|
|
|
3
3
|
import { OFFLINE_TOOLS, OFFLINE_TOOLS_HINT } from '../../constants/offlineTools.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Handler for the
|
|
6
|
+
* Handler for the ping tool
|
|
7
7
|
* Tests connection to Unity Editor
|
|
8
8
|
*/
|
|
9
9
|
export class SystemPingToolHandler extends BaseToolHandler {
|
|
10
10
|
constructor(unityConnection) {
|
|
11
11
|
super(
|
|
12
|
-
'
|
|
12
|
+
'ping',
|
|
13
13
|
'Test connection to Unity Editor',
|
|
14
14
|
{
|
|
15
15
|
type: 'object',
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Handler for the
|
|
4
|
+
* Handler for the refresh_assets tool
|
|
5
5
|
* Triggers Unity to refresh assets and potentially recompile
|
|
6
6
|
*/
|
|
7
7
|
export class SystemRefreshAssetsToolHandler extends BaseToolHandler {
|
|
8
8
|
constructor(unityConnection) {
|
|
9
|
-
super('
|
|
9
|
+
super('refresh_assets', 'Refresh assets and check compilation status.', {
|
|
10
10
|
type: 'object',
|
|
11
11
|
properties: {},
|
|
12
12
|
required: []
|
|
@@ -8,7 +8,7 @@ import * as testRunState from '../../utils/testRunState.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export class TestGetStatusToolHandler extends BaseToolHandler {
|
|
10
10
|
constructor(unityConnection) {
|
|
11
|
-
super('
|
|
11
|
+
super('get_test_status', 'Get current Unity test execution status and results', {
|
|
12
12
|
type: 'object',
|
|
13
13
|
properties: {
|
|
14
14
|
includeTestResults: {
|
|
@@ -8,7 +8,7 @@ import * as testRunState from '../../utils/testRunState.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export class TestRunToolHandler extends BaseToolHandler {
|
|
10
10
|
constructor(unityConnection) {
|
|
11
|
-
super('
|
|
11
|
+
super('run_tests', 'Run Unity NUnit tests in the current project', {
|
|
12
12
|
type: 'object',
|
|
13
13
|
properties: {
|
|
14
14
|
testMode: {
|
|
@@ -2,7 +2,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
2
2
|
|
|
3
3
|
export class UIClickElementToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
|
-
super('
|
|
5
|
+
super('click_ui_element', 'Simulate clicking on UI elements', {
|
|
6
6
|
type: 'object',
|
|
7
7
|
properties: {
|
|
8
8
|
elementPath: {
|
|
@@ -2,7 +2,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
2
2
|
|
|
3
3
|
export class UIFindElementsToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
|
-
super('
|
|
5
|
+
super('find_ui_elements', 'Find UI elements by component type, tag, or name pattern.', {
|
|
6
6
|
type: 'object',
|
|
7
7
|
properties: {
|
|
8
8
|
elementType: {
|
|
@@ -2,7 +2,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
2
2
|
|
|
3
3
|
export class UIGetElementStateToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
|
-
super('
|
|
5
|
+
super('get_ui_element_state', 'Get detailed state information about UI elements', {
|
|
6
6
|
type: 'object',
|
|
7
7
|
properties: {
|
|
8
8
|
elementPath: {
|
|
@@ -2,7 +2,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
2
2
|
|
|
3
3
|
export class UISetElementValueToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
|
-
super('
|
|
5
|
+
super('set_ui_element_value', 'Set values for UI input elements', {
|
|
6
6
|
type: 'object',
|
|
7
7
|
properties: {
|
|
8
8
|
elementPath: {
|
|
@@ -2,7 +2,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
2
2
|
|
|
3
3
|
export class UISimulateInputToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
|
-
super('
|
|
5
|
+
super('simulate_ui_input', 'Simulate complex UI interactions and input sequences', {
|
|
6
6
|
type: 'object',
|
|
7
7
|
properties: {
|
|
8
8
|
// Option 1: Simple single input
|
|
@@ -41,14 +41,14 @@ export class VideoCaptureForToolHandler extends BaseToolHandler {
|
|
|
41
41
|
let needPlay = !!params.play;
|
|
42
42
|
if (params.play === undefined) {
|
|
43
43
|
try {
|
|
44
|
-
const s0 = await this.unityConnection.sendCommand('
|
|
44
|
+
const s0 = await this.unityConnection.sendCommand('get_editor_state', {});
|
|
45
45
|
needPlay = !(s0 && s0.isPlaying);
|
|
46
46
|
} catch {
|
|
47
47
|
needPlay = true;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
if (needPlay) {
|
|
51
|
-
await this.unityConnection.sendCommand('
|
|
51
|
+
await this.unityConnection.sendCommand('play_game', {});
|
|
52
52
|
for (let i = 0; i < 60; i++) {
|
|
53
53
|
const s = await this.unityConnection.sendCommand('get_editor_state', {});
|
|
54
54
|
if (s && s.isPlaying) {
|
|
@@ -61,7 +61,7 @@ export class VideoCaptureForToolHandler extends BaseToolHandler {
|
|
|
61
61
|
|
|
62
62
|
// Start with auto-stop
|
|
63
63
|
const { WORKSPACE_ROOT } = await import('../../core/config.js');
|
|
64
|
-
const startResp = await this.unityConnection.sendCommand('
|
|
64
|
+
const startResp = await this.unityConnection.sendCommand('capture_video_start', {
|
|
65
65
|
captureMode: params.captureMode || 'game',
|
|
66
66
|
width: params.width ?? 1280,
|
|
67
67
|
height: params.height ?? 720,
|
|
@@ -78,14 +78,14 @@ export class VideoCaptureForToolHandler extends BaseToolHandler {
|
|
|
78
78
|
Date.now() + Math.max(0, Math.floor((params.durationSec || 0) * 1000)) + 1500; // small buffer
|
|
79
79
|
let lastStatus = null;
|
|
80
80
|
while (Date.now() < deadline) {
|
|
81
|
-
lastStatus = await this.unityConnection.sendCommand('
|
|
81
|
+
lastStatus = await this.unityConnection.sendCommand('capture_video_status', {});
|
|
82
82
|
if (lastStatus && lastStatus.isRecording === false) break;
|
|
83
83
|
await sleep(250);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// Safety stop if still recording after deadline
|
|
87
87
|
if (lastStatus && lastStatus.isRecording) {
|
|
88
|
-
await this.unityConnection.sendCommand('
|
|
88
|
+
await this.unityConnection.sendCommand('capture_video_stop', {});
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// Final stop result
|
|
@@ -102,7 +102,7 @@ export class VideoCaptureForToolHandler extends BaseToolHandler {
|
|
|
102
102
|
} finally {
|
|
103
103
|
// If we entered play, attempt to leave play (best-effort)
|
|
104
104
|
try {
|
|
105
|
-
if (enteredPlay) await this.unityConnection.sendCommand('
|
|
105
|
+
if (enteredPlay) await this.unityConnection.sendCommand('stop_game', {});
|
|
106
106
|
} catch {}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -6,7 +6,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
6
6
|
export class VideoCaptureStartToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
8
|
super(
|
|
9
|
-
'
|
|
9
|
+
'capture_video_start',
|
|
10
10
|
'Start video recording (Game view). Requires com.unity.recorder.',
|
|
11
11
|
{
|
|
12
12
|
type: 'object',
|
|
@@ -5,7 +5,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
5
5
|
|
|
6
6
|
export class VideoCaptureStatusToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
|
-
super('
|
|
8
|
+
super('capture_video_status', 'Get current video recording status.', {
|
|
9
9
|
type: 'object',
|
|
10
10
|
properties: {}
|
|
11
11
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Handler for the
|
|
2
|
+
* Handler for the capture_video_stop tool
|
|
3
3
|
*/
|
|
4
4
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
5
5
|
|
|
6
6
|
export class VideoCaptureStopToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
|
-
super('
|
|
8
|
+
super('capture_video_stop', 'Stop current video recording and finalize the file.', {
|
|
9
9
|
type: 'object',
|
|
10
10
|
properties: {
|
|
11
11
|
recordingId: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for analyze_scene_contents
|
|
3
3
|
*/
|
|
4
4
|
export const analyzeSceneContentsToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'analyze_scene_contents',
|
|
6
6
|
description: 'Analyze current scene: object counts, types, prefabs, and memory stats.',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for find_by_component
|
|
3
3
|
*/
|
|
4
4
|
export const findByComponentToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'find_by_component',
|
|
6
6
|
description: 'Find GameObjects that have a specific component type (scene/prefabs/all).',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Tool definition for
|
|
1
|
+
// Tool definition for get_animator_state
|
|
2
2
|
export const getAnimatorStateToolDefinition = {
|
|
3
|
-
name: '
|
|
3
|
+
name: 'get_animator_state',
|
|
4
4
|
description: 'Get Animator state: layers, transitions, and parameter values for a GameObject.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -39,9 +39,9 @@ export const getAnimatorStateToolDefinition = {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
// Tool definition for
|
|
42
|
+
// Tool definition for get_animator_runtime_info
|
|
43
43
|
export const getAnimatorRuntimeInfoToolDefinition = {
|
|
44
|
-
name: '
|
|
44
|
+
name: 'get_animator_runtime_info',
|
|
45
45
|
description: 'Get Animator runtime info (IK, root motion, performance) — Play mode only.',
|
|
46
46
|
inputSchema: {
|
|
47
47
|
type: 'object',
|
|
@@ -99,7 +99,7 @@ export async function getAnimatorStateHandler(unityConnection, args) {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
// Send command to Unity (
|
|
102
|
+
// Send command to Unity (UnityConnection normalizes legacy tool names → Unity command type)
|
|
103
103
|
const result = await unityConnection.sendCommand(getAnimatorStateToolDefinition.name, args);
|
|
104
104
|
|
|
105
105
|
// Check for errors
|
|
@@ -221,7 +221,7 @@ export async function getAnimatorRuntimeInfoHandler(unityConnection, args) {
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
// Send command to Unity (
|
|
224
|
+
// Send command to Unity (UnityConnection normalizes legacy tool names → Unity command type)
|
|
225
225
|
const result = await unityConnection.sendCommand(
|
|
226
226
|
getAnimatorRuntimeInfoToolDefinition.name,
|
|
227
227
|
args
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for get_component_values
|
|
3
3
|
*/
|
|
4
4
|
export const getComponentValuesToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'get_component_values',
|
|
6
6
|
description: 'Get properties/values from a component on a GameObject (scene or prefab mode).',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for get_gameobject_details
|
|
3
3
|
*/
|
|
4
4
|
export const getGameObjectDetailsToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'get_gameobject_details',
|
|
6
6
|
description: 'Get details for a GameObject by name or path (children/components/materials).',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Tool definitions for Input Actions analysis
|
|
2
2
|
export const getInputActionsStateToolDefinition = {
|
|
3
|
-
name: '
|
|
3
|
+
name: 'get_input_actions_state',
|
|
4
4
|
description: 'Get Input Actions state: maps, actions, bindings, devices, JSON structure.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -34,7 +34,7 @@ export const getInputActionsStateToolDefinition = {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export const analyzeInputActionsAssetToolDefinition = {
|
|
37
|
-
name: '
|
|
37
|
+
name: 'analyze_input_actions_asset',
|
|
38
38
|
description: 'Analyze an Input Actions asset in detail (statistics + device usage).',
|
|
39
39
|
inputSchema: {
|
|
40
40
|
type: 'object',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for get_object_references
|
|
3
3
|
*/
|
|
4
4
|
export const getObjectReferencesToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'get_object_references',
|
|
6
6
|
description: 'Find references to and from a GameObject (hierarchy/assets/prefabs).',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// Action Map Management
|
|
4
4
|
export const createActionMapToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'create_action_map',
|
|
6
6
|
description: 'Create a new Action Map in an Input Actions asset',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -32,7 +32,7 @@ export const createActionMapToolDefinition = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export const removeActionMapToolDefinition = {
|
|
35
|
-
name: '
|
|
35
|
+
name: 'remove_action_map',
|
|
36
36
|
description: 'Remove an Action Map from an Input Actions asset',
|
|
37
37
|
inputSchema: {
|
|
38
38
|
type: 'object',
|
|
@@ -52,7 +52,7 @@ export const removeActionMapToolDefinition = {
|
|
|
52
52
|
|
|
53
53
|
// Action Management
|
|
54
54
|
export const addInputActionToolDefinition = {
|
|
55
|
-
name: '
|
|
55
|
+
name: 'add_input_action',
|
|
56
56
|
description: 'Add a new Action to an Action Map',
|
|
57
57
|
inputSchema: {
|
|
58
58
|
type: 'object',
|
|
@@ -81,7 +81,7 @@ export const addInputActionToolDefinition = {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
export const removeInputActionToolDefinition = {
|
|
84
|
-
name: '
|
|
84
|
+
name: 'remove_input_action',
|
|
85
85
|
description: 'Remove an Action from an Action Map',
|
|
86
86
|
inputSchema: {
|
|
87
87
|
type: 'object',
|
|
@@ -105,7 +105,7 @@ export const removeInputActionToolDefinition = {
|
|
|
105
105
|
|
|
106
106
|
// Binding Management
|
|
107
107
|
export const addInputBindingToolDefinition = {
|
|
108
|
-
name: '
|
|
108
|
+
name: 'add_input_binding',
|
|
109
109
|
description: 'Add a new Binding to an Action',
|
|
110
110
|
inputSchema: {
|
|
111
111
|
type: 'object',
|
|
@@ -144,7 +144,7 @@ export const addInputBindingToolDefinition = {
|
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
export const removeInputBindingToolDefinition = {
|
|
147
|
-
name: '
|
|
147
|
+
name: 'remove_input_binding',
|
|
148
148
|
description: 'Remove a Binding from an Action',
|
|
149
149
|
inputSchema: {
|
|
150
150
|
type: 'object',
|
|
@@ -175,7 +175,7 @@ export const removeInputBindingToolDefinition = {
|
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
export const removeAllBindingsToolDefinition = {
|
|
178
|
-
name: '
|
|
178
|
+
name: 'remove_all_bindings',
|
|
179
179
|
description: 'Remove all Bindings from an Action',
|
|
180
180
|
inputSchema: {
|
|
181
181
|
type: 'object',
|
|
@@ -198,7 +198,7 @@ export const removeAllBindingsToolDefinition = {
|
|
|
198
198
|
};
|
|
199
199
|
|
|
200
200
|
export const createCompositeBindingToolDefinition = {
|
|
201
|
-
name: '
|
|
201
|
+
name: 'create_composite_binding',
|
|
202
202
|
description: 'Create a composite binding (e.g., 2D Vector for WASD movement)',
|
|
203
203
|
inputSchema: {
|
|
204
204
|
type: 'object',
|
|
@@ -248,7 +248,7 @@ export const createCompositeBindingToolDefinition = {
|
|
|
248
248
|
|
|
249
249
|
// Control Scheme Management
|
|
250
250
|
export const manageControlSchemesToolDefinition = {
|
|
251
|
-
name: '
|
|
251
|
+
name: 'manage_control_schemes',
|
|
252
252
|
description: 'Manage Control Schemes in an Input Actions asset',
|
|
253
253
|
inputSchema: {
|
|
254
254
|
type: 'object',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for create_scene
|
|
3
3
|
*/
|
|
4
4
|
export const createSceneToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'create_scene',
|
|
6
6
|
description: 'Create a new scene in Unity',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -74,7 +74,7 @@ export async function createSceneHandler(unityConnection, args) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// Send command to Unity
|
|
77
|
-
const result = await unityConnection.sendCommand('
|
|
77
|
+
const result = await unityConnection.sendCommand('create_scene', args);
|
|
78
78
|
|
|
79
79
|
// Handle Unity response
|
|
80
80
|
if (result.status === 'error') {
|