@akiojin/unity-mcp-server 2.40.2 → 2.40.3
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/README.md +21 -0
- package/bin/unity-mcp-server +1 -1
- package/package.json +1 -1
- package/src/core/codeIndex.js +64 -15
- package/src/core/server.js +3 -34
- package/src/handlers/analysis/AnalyzeSceneContentsToolHandler.js +27 -24
- package/src/handlers/analysis/FindByComponentToolHandler.js +4 -1
- package/src/handlers/analysis/GetAnimatorStateToolHandler.js +5 -5
- package/src/handlers/analysis/GetComponentValuesToolHandler.js +4 -1
- package/src/handlers/analysis/GetGameObjectDetailsToolHandler.js +27 -24
- package/src/handlers/analysis/GetInputActionsStateToolHandler.js +5 -5
- package/src/handlers/analysis/GetObjectReferencesToolHandler.js +4 -1
- package/src/handlers/asset/AssetDatabaseManageToolHandler.js +24 -6
- package/src/handlers/asset/AssetDependencyAnalyzeToolHandler.js +21 -11
- package/src/handlers/asset/AssetImportSettingsManageToolHandler.js +7 -7
- package/src/handlers/asset/AssetMaterialCreateToolHandler.js +78 -81
- package/src/handlers/asset/AssetMaterialModifyToolHandler.js +57 -61
- package/src/handlers/asset/AssetPrefabCreateToolHandler.js +61 -64
- package/src/handlers/asset/AssetPrefabExitModeToolHandler.js +9 -13
- package/src/handlers/asset/AssetPrefabInstantiateToolHandler.js +110 -116
- package/src/handlers/asset/AssetPrefabModifyToolHandler.js +58 -58
- package/src/handlers/asset/AssetPrefabOpenToolHandler.js +7 -5
- package/src/handlers/asset/AssetPrefabSaveToolHandler.js +13 -6
- package/src/handlers/compilation/CompilationGetStateToolHandler.js +4 -3
- package/src/handlers/component/ComponentAddToolHandler.js +2 -2
- package/src/handlers/component/ComponentGetTypesToolHandler.js +17 -21
- package/src/handlers/component/ComponentListToolHandler.js +5 -3
- package/src/handlers/component/ComponentModifyToolHandler.js +3 -3
- package/src/handlers/component/ComponentRemoveToolHandler.js +2 -2
- package/src/handlers/console/ConsoleClearToolHandler.js +36 -46
- package/src/handlers/editor/EditorLayersManageToolHandler.js +7 -6
- package/src/handlers/editor/EditorTagsManageToolHandler.js +20 -11
- package/src/handlers/editor/EditorToolsManageToolHandler.js +2 -2
- package/src/handlers/editor/EditorWindowsManageToolHandler.js +6 -5
- package/src/handlers/gameobject/GameObjectCreateToolHandler.js +62 -66
- package/src/handlers/gameobject/GameObjectDeleteToolHandler.js +9 -9
- package/src/handlers/gameobject/GameObjectFindToolHandler.js +13 -11
- package/src/handlers/gameobject/GameObjectGetHierarchyToolHandler.js +22 -16
- package/src/handlers/input/InputActionAddToolHandler.js +2 -2
- package/src/handlers/input/InputActionMapCreateToolHandler.js +2 -2
- package/src/handlers/input/InputActionMapRemoveToolHandler.js +2 -2
- package/src/handlers/input/InputActionRemoveToolHandler.js +2 -2
- package/src/handlers/input/InputBindingAddToolHandler.js +2 -2
- package/src/handlers/input/InputBindingCompositeCreateToolHandler.js +2 -2
- package/src/handlers/input/InputBindingRemoveAllToolHandler.js +2 -2
- package/src/handlers/input/InputBindingRemoveToolHandler.js +2 -2
- package/src/handlers/input/InputControlSchemesManageToolHandler.js +2 -2
- package/src/handlers/package/PackageManagerToolHandler.js +41 -44
- package/src/handlers/package/RegistryConfigToolHandler.js +28 -7
- package/src/handlers/playmode/PlaymodeGetStateToolHandler.js +12 -16
- package/src/handlers/playmode/PlaymodePauseToolHandler.js +8 -12
- package/src/handlers/playmode/PlaymodeWaitForStateToolHandler.js +6 -3
- package/src/handlers/scene/GetSceneInfoToolHandler.js +11 -11
- package/src/handlers/scene/SceneCreateToolHandler.js +28 -31
- package/src/handlers/scene/SceneListToolHandler.js +21 -24
- package/src/handlers/scene/SceneLoadToolHandler.js +27 -29
- package/src/handlers/scene/SceneSaveToolHandler.js +19 -22
- package/src/handlers/screenshot/ScreenshotCaptureToolHandler.js +88 -66
- package/src/handlers/script/CodeIndexStatusToolHandler.js +4 -3
- package/src/handlers/script/CodeIndexUpdateToolHandler.js +24 -14
- package/src/handlers/script/ScriptCreateClassToolHandler.js +44 -9
- package/src/handlers/script/ScriptPackagesListToolHandler.js +91 -91
- package/src/handlers/script/ScriptRefactorRenameToolHandler.js +80 -71
- package/src/handlers/script/ScriptRemoveSymbolToolHandler.js +21 -7
- package/src/handlers/script/ScriptSearchToolHandler.js +299 -266
- package/src/handlers/script/ScriptSymbolsGetToolHandler.js +88 -79
- package/src/handlers/settings/SettingsGetToolHandler.js +28 -13
- package/src/handlers/settings/SettingsUpdateToolHandler.js +20 -6
- package/src/handlers/ui/UIClickElementToolHandler.js +87 -96
- package/src/handlers/ui/UIFindElementsToolHandler.js +45 -55
- package/src/handlers/ui/UIGetElementStateToolHandler.js +35 -43
- package/src/handlers/ui/UISetElementValueToolHandler.js +42 -49
- package/src/handlers/ui/UISimulateInputToolHandler.js +134 -136
- package/src/handlers/video/VideoCaptureForToolHandler.js +24 -7
- package/src/lsp/LspRpcClient.js +24 -12
- package/src/tools/analysis/analyzeSceneContents.js +85 -85
- package/src/tools/analysis/findByComponent.js +73 -73
- package/src/tools/analysis/getAnimatorState.js +287 -287
- package/src/tools/analysis/getComponentValues.js +161 -161
- package/src/tools/analysis/getGameObjectDetails.js +138 -138
- package/src/tools/analysis/getInputActionsState.js +291 -291
- package/src/tools/analysis/getObjectReferences.js +72 -72
- package/src/tools/input/inputActionsEditor.js +522 -474
- package/src/tools/scene/createScene.js +98 -97
- package/src/tools/scene/getSceneInfo.js +82 -81
- package/src/tools/scene/listScenes.js +70 -69
- package/src/tools/scene/loadScene.js +108 -106
- package/src/tools/scene/saveScene.js +78 -77
- package/src/tools/system/ping.js +9 -12
- package/src/utils/validators.js +2 -2
|
@@ -5,37 +5,36 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export class ConsoleClearToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
|
-
super(
|
|
9
|
-
'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type: 'boolean',
|
|
16
|
-
description: 'Clear console when entering play mode. Unity default: false. Set to true for cleaner testing sessions'
|
|
17
|
-
},
|
|
18
|
-
clearOnRecompile: {
|
|
19
|
-
type: 'boolean',
|
|
20
|
-
description: 'Clear console on script recompilation. Unity default: false. Set to true to focus on current compilation errors'
|
|
21
|
-
},
|
|
22
|
-
clearOnBuild: {
|
|
23
|
-
type: 'boolean',
|
|
24
|
-
description: 'Clear console when building. Unity default: false. Set to true for clean build logs'
|
|
25
|
-
},
|
|
26
|
-
preserveWarnings: {
|
|
27
|
-
type: 'boolean',
|
|
28
|
-
description: 'Preserve warning messages when clearing (default: false)'
|
|
29
|
-
},
|
|
30
|
-
preserveErrors: {
|
|
31
|
-
type: 'boolean',
|
|
32
|
-
description: 'Preserve error messages when clearing (default: false)'
|
|
33
|
-
}
|
|
8
|
+
super('console_clear', 'Clear Console logs (optionally set auto-clear and preserve levels).', {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
clearOnPlay: {
|
|
12
|
+
type: 'boolean',
|
|
13
|
+
description:
|
|
14
|
+
'Clear console when entering play mode. Unity default: false. Set to true for cleaner testing sessions'
|
|
34
15
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
16
|
+
clearOnRecompile: {
|
|
17
|
+
type: 'boolean',
|
|
18
|
+
description:
|
|
19
|
+
'Clear console on script recompilation. Unity default: false. Set to true to focus on current compilation errors'
|
|
20
|
+
},
|
|
21
|
+
clearOnBuild: {
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
description:
|
|
24
|
+
'Clear console when building. Unity default: false. Set to true for clean build logs'
|
|
25
|
+
},
|
|
26
|
+
preserveWarnings: {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
description: 'Preserve warning messages when clearing (default: false)'
|
|
29
|
+
},
|
|
30
|
+
preserveErrors: {
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
description: 'Preserve error messages when clearing (default: false)'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
required: []
|
|
36
|
+
});
|
|
37
|
+
|
|
39
38
|
this.unityConnection = unityConnection;
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -45,13 +44,8 @@ export class ConsoleClearToolHandler extends BaseToolHandler {
|
|
|
45
44
|
* @throws {Error} If validation fails
|
|
46
45
|
*/
|
|
47
46
|
validate(params) {
|
|
48
|
-
const {
|
|
49
|
-
|
|
50
|
-
clearOnRecompile,
|
|
51
|
-
clearOnBuild,
|
|
52
|
-
preserveWarnings,
|
|
53
|
-
preserveErrors
|
|
54
|
-
} = params;
|
|
47
|
+
const { clearOnPlay, clearOnRecompile, clearOnBuild, preserveWarnings, preserveErrors } =
|
|
48
|
+
params;
|
|
55
49
|
|
|
56
50
|
// Validate boolean parameters
|
|
57
51
|
if (clearOnPlay !== undefined && typeof clearOnPlay !== 'boolean') {
|
|
@@ -75,9 +69,10 @@ export class ConsoleClearToolHandler extends BaseToolHandler {
|
|
|
75
69
|
}
|
|
76
70
|
|
|
77
71
|
// Validate logical consistency
|
|
78
|
-
const isClearing =
|
|
72
|
+
const isClearing =
|
|
73
|
+
clearOnPlay !== false || clearOnRecompile !== false || clearOnBuild !== false;
|
|
79
74
|
const isPreserving = preserveWarnings === true || preserveErrors === true;
|
|
80
|
-
|
|
75
|
+
|
|
81
76
|
if (isPreserving && !isClearing) {
|
|
82
77
|
throw new Error('Cannot preserve specific log types when not clearing console');
|
|
83
78
|
}
|
|
@@ -89,13 +84,8 @@ export class ConsoleClearToolHandler extends BaseToolHandler {
|
|
|
89
84
|
* @returns {Promise<Object>} The result of the clear operation
|
|
90
85
|
*/
|
|
91
86
|
async execute(params) {
|
|
92
|
-
const {
|
|
93
|
-
|
|
94
|
-
clearOnRecompile,
|
|
95
|
-
clearOnBuild,
|
|
96
|
-
preserveWarnings,
|
|
97
|
-
preserveErrors
|
|
98
|
-
} = params;
|
|
87
|
+
const { clearOnPlay, clearOnRecompile, clearOnBuild, preserveWarnings, preserveErrors } =
|
|
88
|
+
params;
|
|
99
89
|
|
|
100
90
|
// Ensure connection to Unity
|
|
101
91
|
if (!this.unityConnection.isConnected()) {
|
|
@@ -18,7 +18,8 @@ export class EditorLayersManageToolHandler extends BaseToolHandler {
|
|
|
18
18
|
},
|
|
19
19
|
layerName: {
|
|
20
20
|
type: 'string',
|
|
21
|
-
description:
|
|
21
|
+
description:
|
|
22
|
+
'Layer name (required for add/remove/get_by_name). Letters/numbers/space/_ only.'
|
|
22
23
|
},
|
|
23
24
|
layerIndex: {
|
|
24
25
|
type: 'number',
|
|
@@ -68,13 +69,13 @@ export class EditorLayersManageToolHandler extends BaseToolHandler {
|
|
|
68
69
|
throw new Error('layerName is reserved');
|
|
69
70
|
}
|
|
70
71
|
break;
|
|
71
|
-
|
|
72
|
+
|
|
72
73
|
case 'get_by_name':
|
|
73
74
|
if (layerName === undefined || layerName === null) {
|
|
74
75
|
throw new Error('layerName is required for get_by_name action');
|
|
75
76
|
}
|
|
76
77
|
break;
|
|
77
|
-
|
|
78
|
+
|
|
78
79
|
case 'get_by_index':
|
|
79
80
|
if (layerIndex === undefined || layerIndex === null) {
|
|
80
81
|
throw new Error('layerIndex is required for get_by_index action');
|
|
@@ -106,13 +107,13 @@ export class EditorLayersManageToolHandler extends BaseToolHandler {
|
|
|
106
107
|
if (!this.unityConnection.isConnected()) {
|
|
107
108
|
await this.unityConnection.connect();
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
+
|
|
110
111
|
const result = await this.unityConnection.sendCommand('manage_layers', params);
|
|
111
|
-
|
|
112
|
+
|
|
112
113
|
if (result.error) {
|
|
113
114
|
throw new Error(result.error);
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
|
|
116
117
|
return result;
|
|
117
118
|
}
|
|
118
119
|
|
|
@@ -24,11 +24,19 @@ export class EditorTagsManageToolHandler extends BaseToolHandler {
|
|
|
24
24
|
required: ['action']
|
|
25
25
|
}
|
|
26
26
|
);
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
this.unityConnection = unityConnection;
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
// Reserved Unity tags that cannot be removed
|
|
31
|
-
this.RESERVED_TAGS = [
|
|
31
|
+
this.RESERVED_TAGS = [
|
|
32
|
+
'Untagged',
|
|
33
|
+
'Respawn',
|
|
34
|
+
'Finish',
|
|
35
|
+
'EditorOnly',
|
|
36
|
+
'MainCamera',
|
|
37
|
+
'Player',
|
|
38
|
+
'GameController'
|
|
39
|
+
];
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
/**
|
|
@@ -37,17 +45,17 @@ export class EditorTagsManageToolHandler extends BaseToolHandler {
|
|
|
37
45
|
*/
|
|
38
46
|
validate(params) {
|
|
39
47
|
const { action, tagName } = params;
|
|
40
|
-
|
|
48
|
+
|
|
41
49
|
// Check if action is provided
|
|
42
50
|
if (!action) {
|
|
43
51
|
throw new Error('action is required');
|
|
44
52
|
}
|
|
45
|
-
|
|
53
|
+
|
|
46
54
|
// Check if action is valid
|
|
47
55
|
if (!['add', 'remove', 'get'].includes(action)) {
|
|
48
56
|
throw new Error('action must be one of: add, remove, get');
|
|
49
57
|
}
|
|
50
|
-
|
|
58
|
+
|
|
51
59
|
// For add and remove actions, tagName is required
|
|
52
60
|
if (action === 'add' || action === 'remove') {
|
|
53
61
|
if (tagName === undefined || tagName === null) {
|
|
@@ -57,21 +65,22 @@ export class EditorTagsManageToolHandler extends BaseToolHandler {
|
|
|
57
65
|
throw new Error('tagName cannot be empty');
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
|
-
|
|
68
|
+
|
|
61
69
|
// Validate tag name if provided
|
|
62
70
|
if (tagName !== undefined && tagName !== '') {
|
|
63
|
-
|
|
64
71
|
// Check for invalid characters (Unity tag names should be alphanumeric with no spaces or special characters)
|
|
65
72
|
if (!/^[a-zA-Z0-9_]+$/.test(tagName)) {
|
|
66
|
-
throw new Error(
|
|
73
|
+
throw new Error(
|
|
74
|
+
'tagName contains invalid characters. Only letters, numbers, and underscores are allowed'
|
|
75
|
+
);
|
|
67
76
|
}
|
|
68
|
-
|
|
77
|
+
|
|
69
78
|
// Check for reserved tag names when adding
|
|
70
79
|
if (action === 'add' && this.RESERVED_TAGS.includes(tagName)) {
|
|
71
80
|
throw new Error(`tagName is reserved`);
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
|
-
|
|
83
|
+
|
|
75
84
|
// Call parent validation last to avoid conflicts
|
|
76
85
|
super.validate(params);
|
|
77
86
|
}
|
|
@@ -46,7 +46,7 @@ export class EditorToolsManageToolHandler extends BaseToolHandler {
|
|
|
46
46
|
if (params.toolName === undefined || params.toolName === null) {
|
|
47
47
|
throw new Error(`toolName is required for ${params.action} action`);
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
if (params.toolName === '') {
|
|
51
51
|
throw new Error('toolName cannot be empty');
|
|
52
52
|
}
|
|
@@ -60,7 +60,7 @@ export class EditorToolsManageToolHandler extends BaseToolHandler {
|
|
|
60
60
|
|
|
61
61
|
async execute(params) {
|
|
62
62
|
this.validate(params);
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
if (!this.unityConnection.isConnected()) {
|
|
65
65
|
await this.unityConnection.connect();
|
|
66
66
|
}
|
|
@@ -18,7 +18,8 @@ export class EditorWindowsManageToolHandler extends BaseToolHandler {
|
|
|
18
18
|
},
|
|
19
19
|
windowType: {
|
|
20
20
|
type: 'string',
|
|
21
|
-
description:
|
|
21
|
+
description:
|
|
22
|
+
'Window type (e.g., SceneView, GameView, InspectorWindow). Required for focus/get_state.'
|
|
22
23
|
},
|
|
23
24
|
includeHidden: {
|
|
24
25
|
type: 'boolean',
|
|
@@ -53,7 +54,7 @@ export class EditorWindowsManageToolHandler extends BaseToolHandler {
|
|
|
53
54
|
if (windowType === undefined || windowType === null) {
|
|
54
55
|
throw new Error(`windowType is required for ${action} action`);
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
|
|
57
58
|
if (windowType === '') {
|
|
58
59
|
throw new Error('windowType cannot be empty');
|
|
59
60
|
}
|
|
@@ -71,13 +72,13 @@ export class EditorWindowsManageToolHandler extends BaseToolHandler {
|
|
|
71
72
|
if (!this.unityConnection.isConnected()) {
|
|
72
73
|
await this.unityConnection.connect();
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
|
|
75
76
|
const result = await this.unityConnection.sendCommand('manage_windows', params);
|
|
76
|
-
|
|
77
|
+
|
|
77
78
|
if (result.error) {
|
|
78
79
|
throw new Error(result.error);
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
|
|
81
82
|
return result;
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -7,67 +7,63 @@ import { validateVector3, validateLayer } from '../../utils/validators.js';
|
|
|
7
7
|
*/
|
|
8
8
|
export class GameObjectCreateToolHandler extends BaseToolHandler {
|
|
9
9
|
constructor(unityConnection) {
|
|
10
|
-
super(
|
|
11
|
-
'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
type: '
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
x: { type: 'number' },
|
|
30
|
-
y: { type: 'number' },
|
|
31
|
-
z: { type: 'number' }
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
rotation: {
|
|
35
|
-
type: 'object',
|
|
36
|
-
description: 'Rotation in Euler angles',
|
|
37
|
-
properties: {
|
|
38
|
-
x: { type: 'number' },
|
|
39
|
-
y: { type: 'number' },
|
|
40
|
-
z: { type: 'number' }
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
scale: {
|
|
44
|
-
type: 'object',
|
|
45
|
-
description: 'Local scale',
|
|
46
|
-
properties: {
|
|
47
|
-
x: { type: 'number' },
|
|
48
|
-
y: { type: 'number' },
|
|
49
|
-
z: { type: 'number' }
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
parentPath: {
|
|
53
|
-
type: 'string',
|
|
54
|
-
description: 'Path to parent GameObject (e.g., "/Parent/Child")'
|
|
55
|
-
},
|
|
56
|
-
tag: {
|
|
57
|
-
type: 'string',
|
|
58
|
-
description: 'Tag to assign to the GameObject'
|
|
59
|
-
},
|
|
60
|
-
layer: {
|
|
61
|
-
type: 'number',
|
|
62
|
-
description: 'Layer index (0-31)',
|
|
63
|
-
minimum: 0,
|
|
64
|
-
maximum: 31
|
|
10
|
+
super('gameobject_create', 'Create a GameObject in Unity scene', {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
name: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'Name of the GameObject (default: "GameObject")'
|
|
16
|
+
},
|
|
17
|
+
primitiveType: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
description: 'Type of primitive to create',
|
|
20
|
+
enum: ['cube', 'sphere', 'cylinder', 'capsule', 'plane', 'quad']
|
|
21
|
+
},
|
|
22
|
+
position: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
description: 'World position',
|
|
25
|
+
properties: {
|
|
26
|
+
x: { type: 'number' },
|
|
27
|
+
y: { type: 'number' },
|
|
28
|
+
z: { type: 'number' }
|
|
65
29
|
}
|
|
66
30
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
31
|
+
rotation: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
description: 'Rotation in Euler angles',
|
|
34
|
+
properties: {
|
|
35
|
+
x: { type: 'number' },
|
|
36
|
+
y: { type: 'number' },
|
|
37
|
+
z: { type: 'number' }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
scale: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
description: 'Local scale',
|
|
43
|
+
properties: {
|
|
44
|
+
x: { type: 'number' },
|
|
45
|
+
y: { type: 'number' },
|
|
46
|
+
z: { type: 'number' }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
parentPath: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
description: 'Path to parent GameObject (e.g., "/Parent/Child")'
|
|
52
|
+
},
|
|
53
|
+
tag: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'Tag to assign to the GameObject'
|
|
56
|
+
},
|
|
57
|
+
layer: {
|
|
58
|
+
type: 'number',
|
|
59
|
+
description: 'Layer index (0-31)',
|
|
60
|
+
minimum: 0,
|
|
61
|
+
maximum: 31
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
required: []
|
|
65
|
+
});
|
|
66
|
+
|
|
71
67
|
this.unityConnection = unityConnection;
|
|
72
68
|
}
|
|
73
69
|
|
|
@@ -78,7 +74,7 @@ export class GameObjectCreateToolHandler extends BaseToolHandler {
|
|
|
78
74
|
*/
|
|
79
75
|
validate(params) {
|
|
80
76
|
super.validate(params);
|
|
81
|
-
|
|
77
|
+
|
|
82
78
|
// Validate primitive type if provided
|
|
83
79
|
if (params.primitiveType) {
|
|
84
80
|
const validTypes = ['cube', 'sphere', 'cylinder', 'capsule', 'plane', 'quad'];
|
|
@@ -86,12 +82,12 @@ export class GameObjectCreateToolHandler extends BaseToolHandler {
|
|
|
86
82
|
throw new Error(`primitiveType must be one of: ${validTypes.join(', ')}`);
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
|
-
|
|
85
|
+
|
|
90
86
|
// Validate vector3 properties
|
|
91
87
|
if (params.position) validateVector3(params.position, 'position');
|
|
92
88
|
if (params.rotation) validateVector3(params.rotation, 'rotation');
|
|
93
89
|
if (params.scale) validateVector3(params.scale, 'scale');
|
|
94
|
-
|
|
90
|
+
|
|
95
91
|
// Validate layer
|
|
96
92
|
if (params.layer !== undefined) {
|
|
97
93
|
validateLayer(Number(params.layer));
|
|
@@ -105,7 +101,7 @@ export class GameObjectCreateToolHandler extends BaseToolHandler {
|
|
|
105
101
|
*/
|
|
106
102
|
async execute(params) {
|
|
107
103
|
console.error('[CreateGameObject] Starting execution with params:', params);
|
|
108
|
-
|
|
104
|
+
|
|
109
105
|
// Ensure connected
|
|
110
106
|
if (!this.unityConnection.isConnected()) {
|
|
111
107
|
console.error('[CreateGameObject] Not connected to Unity, attempting to connect...');
|
|
@@ -114,18 +110,18 @@ export class GameObjectCreateToolHandler extends BaseToolHandler {
|
|
|
114
110
|
} else {
|
|
115
111
|
console.error('[CreateGameObject] Already connected to Unity');
|
|
116
112
|
}
|
|
117
|
-
|
|
113
|
+
|
|
118
114
|
// Send create_gameobject command
|
|
119
115
|
console.error('[CreateGameObject] Sending command to Unity...');
|
|
120
116
|
const result = await this.unityConnection.sendCommand('create_gameobject', params);
|
|
121
117
|
console.error('[CreateGameObject] Received result from Unity:', result);
|
|
122
|
-
|
|
118
|
+
|
|
123
119
|
// Check for errors from Unity
|
|
124
120
|
if (result.error) {
|
|
125
121
|
console.error('[CreateGameObject] Unity returned error:', result.error);
|
|
126
122
|
throw new Error(result.error);
|
|
127
123
|
}
|
|
128
|
-
|
|
124
|
+
|
|
129
125
|
return result;
|
|
130
126
|
}
|
|
131
127
|
}
|
|
@@ -31,7 +31,7 @@ export class GameObjectDeleteToolHandler extends BaseToolHandler {
|
|
|
31
31
|
required: []
|
|
32
32
|
}
|
|
33
33
|
);
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
this.unityConnection = unityConnection;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -42,18 +42,18 @@ export class GameObjectDeleteToolHandler extends BaseToolHandler {
|
|
|
42
42
|
*/
|
|
43
43
|
validate(params) {
|
|
44
44
|
super.validate(params);
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
// Either path or paths must be provided
|
|
47
47
|
if (!params.path && (!params.paths || params.paths.length === 0)) {
|
|
48
48
|
throw new Error('Either "path" or "paths" parameter must be provided');
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
// Validate paths array if provided
|
|
52
52
|
if (params.paths) {
|
|
53
53
|
if (!Array.isArray(params.paths)) {
|
|
54
54
|
throw new Error('paths must be an array of strings');
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
for (const path of params.paths) {
|
|
58
58
|
if (typeof path !== 'string') {
|
|
59
59
|
throw new Error('All paths must be strings');
|
|
@@ -72,15 +72,15 @@ export class GameObjectDeleteToolHandler extends BaseToolHandler {
|
|
|
72
72
|
if (!this.unityConnection.isConnected()) {
|
|
73
73
|
await this.unityConnection.connect();
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
// Send delete_gameobject command
|
|
77
77
|
const result = await this.unityConnection.sendCommand('delete_gameobject', params);
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
// Check for errors from Unity
|
|
80
80
|
if (result.error) {
|
|
81
81
|
throw new Error(result.error);
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
// Add summary
|
|
85
85
|
if (result.deletedCount !== undefined) {
|
|
86
86
|
if (result.deletedCount === 0) {
|
|
@@ -90,12 +90,12 @@ export class GameObjectDeleteToolHandler extends BaseToolHandler {
|
|
|
90
90
|
} else {
|
|
91
91
|
result.summary = `Deleted ${result.deletedCount} GameObjects`;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
if (result.notFoundCount > 0) {
|
|
95
95
|
result.summary += ` (${result.notFoundCount} not found)`;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
return result;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -34,7 +34,7 @@ export class GameObjectFindToolHandler extends BaseToolHandler {
|
|
|
34
34
|
required: []
|
|
35
35
|
}
|
|
36
36
|
);
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
this.unityConnection = unityConnection;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -45,12 +45,12 @@ export class GameObjectFindToolHandler extends BaseToolHandler {
|
|
|
45
45
|
*/
|
|
46
46
|
validate(params) {
|
|
47
47
|
super.validate(params);
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
// At least one search criteria must be provided
|
|
50
50
|
if (!params.name && !params.tag && params.layer === undefined) {
|
|
51
51
|
throw new Error('At least one search criteria (name, tag, or layer) must be provided');
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
// Validate layer
|
|
55
55
|
if (params.layer !== undefined) {
|
|
56
56
|
const layer = Number(params.layer);
|
|
@@ -70,20 +70,20 @@ export class GameObjectFindToolHandler extends BaseToolHandler {
|
|
|
70
70
|
if (!this.unityConnection.isConnected()) {
|
|
71
71
|
await this.unityConnection.connect();
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
// Send find_gameobject command
|
|
75
75
|
const result = await this.unityConnection.sendCommand('find_gameobject', params);
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
// Check for errors from Unity
|
|
78
78
|
if (result.error) {
|
|
79
79
|
throw new Error(result.error);
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
// Add summary information
|
|
83
83
|
if (result.objects && Array.isArray(result.objects)) {
|
|
84
84
|
result.summary = this.generateSummary(result.objects, params);
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
return result;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -95,9 +95,11 @@ export class GameObjectFindToolHandler extends BaseToolHandler {
|
|
|
95
95
|
*/
|
|
96
96
|
generateSummary(objects, searchParams) {
|
|
97
97
|
const parts = [];
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
if (searchParams.name) {
|
|
100
|
-
parts.push(
|
|
100
|
+
parts.push(
|
|
101
|
+
`name${searchParams.exactMatch === false ? ' containing' : ''} "${searchParams.name}"`
|
|
102
|
+
);
|
|
101
103
|
}
|
|
102
104
|
if (searchParams.tag) {
|
|
103
105
|
parts.push(`tag "${searchParams.tag}"`);
|
|
@@ -105,9 +107,9 @@ export class GameObjectFindToolHandler extends BaseToolHandler {
|
|
|
105
107
|
if (searchParams.layer !== undefined) {
|
|
106
108
|
parts.push(`layer ${searchParams.layer}`);
|
|
107
109
|
}
|
|
108
|
-
|
|
110
|
+
|
|
109
111
|
const criteria = parts.join(', ');
|
|
110
|
-
|
|
112
|
+
|
|
111
113
|
if (objects.length === 0) {
|
|
112
114
|
return `No GameObjects found matching ${criteria}`;
|
|
113
115
|
} else if (objects.length === 1) {
|