@akiojin/unity-mcp-server 2.40.2 → 2.40.4
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 +4 -3
- package/src/core/codeIndex.js +143 -20
- package/src/core/indexWatcher.js +11 -0
- package/src/core/server.js +9 -34
- package/src/core/sqliteFallback.js +75 -0
- 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/CodeIndexBuildToolHandler.js +7 -0
- 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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import {
|
|
3
|
+
getInputActionsStateToolDefinition,
|
|
4
|
+
analyzeInputActionsAssetToolDefinition,
|
|
5
|
+
getInputActionsStateHandler,
|
|
6
|
+
analyzeInputActionsAssetHandler
|
|
7
7
|
} from '../../tools/analysis/getInputActionsState.js';
|
|
8
8
|
|
|
9
9
|
export class GetInputActionsStateToolHandler extends BaseToolHandler {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getObjectReferencesToolDefinition,
|
|
4
|
+
getObjectReferencesHandler
|
|
5
|
+
} from '../../tools/analysis/getObjectReferences.js';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* Handler for the analysis_object_references_get tool
|
|
@@ -13,7 +13,16 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
|
|
|
13
13
|
properties: {
|
|
14
14
|
action: {
|
|
15
15
|
type: 'string',
|
|
16
|
-
enum: [
|
|
16
|
+
enum: [
|
|
17
|
+
'find_assets',
|
|
18
|
+
'get_asset_info',
|
|
19
|
+
'create_folder',
|
|
20
|
+
'delete_asset',
|
|
21
|
+
'move_asset',
|
|
22
|
+
'copy_asset',
|
|
23
|
+
'refresh',
|
|
24
|
+
'save'
|
|
25
|
+
],
|
|
17
26
|
description: 'The action to perform'
|
|
18
27
|
},
|
|
19
28
|
filter: {
|
|
@@ -53,7 +62,16 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
|
|
|
53
62
|
throw new Error('action is required');
|
|
54
63
|
}
|
|
55
64
|
|
|
56
|
-
const validActions = [
|
|
65
|
+
const validActions = [
|
|
66
|
+
'find_assets',
|
|
67
|
+
'get_asset_info',
|
|
68
|
+
'create_folder',
|
|
69
|
+
'delete_asset',
|
|
70
|
+
'move_asset',
|
|
71
|
+
'copy_asset',
|
|
72
|
+
'refresh',
|
|
73
|
+
'save'
|
|
74
|
+
];
|
|
57
75
|
if (!validActions.includes(params.action)) {
|
|
58
76
|
throw new Error(`action must be one of: ${validActions.join(', ')}`);
|
|
59
77
|
}
|
|
@@ -123,7 +141,7 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
|
|
|
123
141
|
|
|
124
142
|
async execute(params) {
|
|
125
143
|
this.validate(params);
|
|
126
|
-
|
|
144
|
+
|
|
127
145
|
if (!this.unityConnection.isConnected()) {
|
|
128
146
|
await this.unityConnection.connect();
|
|
129
147
|
}
|
|
@@ -184,8 +202,8 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
|
|
|
184
202
|
}
|
|
185
203
|
},
|
|
186
204
|
{
|
|
187
|
-
input: {
|
|
188
|
-
action: 'move_asset',
|
|
205
|
+
input: {
|
|
206
|
+
action: 'move_asset',
|
|
189
207
|
fromPath: 'Assets/icon.png',
|
|
190
208
|
toPath: 'Assets/Textures/icon.png'
|
|
191
209
|
},
|
|
@@ -218,4 +236,4 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
|
|
|
218
236
|
}
|
|
219
237
|
];
|
|
220
238
|
}
|
|
221
|
-
}
|
|
239
|
+
}
|
|
@@ -13,7 +13,14 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
|
|
|
13
13
|
properties: {
|
|
14
14
|
action: {
|
|
15
15
|
type: 'string',
|
|
16
|
-
enum: [
|
|
16
|
+
enum: [
|
|
17
|
+
'get_dependencies',
|
|
18
|
+
'get_dependents',
|
|
19
|
+
'analyze_circular',
|
|
20
|
+
'find_unused',
|
|
21
|
+
'analyze_size_impact',
|
|
22
|
+
'validate_references'
|
|
23
|
+
],
|
|
17
24
|
description: 'The analysis action to perform'
|
|
18
25
|
},
|
|
19
26
|
assetPath: {
|
|
@@ -40,7 +47,14 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
|
|
|
40
47
|
throw new Error('action is required');
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
const validActions = [
|
|
50
|
+
const validActions = [
|
|
51
|
+
'get_dependencies',
|
|
52
|
+
'get_dependents',
|
|
53
|
+
'analyze_circular',
|
|
54
|
+
'find_unused',
|
|
55
|
+
'analyze_size_impact',
|
|
56
|
+
'validate_references'
|
|
57
|
+
];
|
|
44
58
|
if (!validActions.includes(params.action)) {
|
|
45
59
|
throw new Error(`action must be one of: ${validActions.join(', ')}`);
|
|
46
60
|
}
|
|
@@ -51,11 +65,11 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
|
|
|
51
65
|
if (params.assetPath === undefined || params.assetPath === null) {
|
|
52
66
|
throw new Error(`assetPath is required for ${params.action} action`);
|
|
53
67
|
}
|
|
54
|
-
|
|
68
|
+
|
|
55
69
|
if (params.assetPath === '') {
|
|
56
70
|
throw new Error('assetPath cannot be empty');
|
|
57
71
|
}
|
|
58
|
-
|
|
72
|
+
|
|
59
73
|
// Validate assetPath starts with "Assets/"
|
|
60
74
|
if (!params.assetPath.startsWith('Assets/')) {
|
|
61
75
|
throw new Error('assetPath must start with "Assets/"');
|
|
@@ -65,7 +79,7 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
|
|
|
65
79
|
|
|
66
80
|
async execute(params) {
|
|
67
81
|
this.validate(params);
|
|
68
|
-
|
|
82
|
+
|
|
69
83
|
if (!this.unityConnection.isConnected()) {
|
|
70
84
|
await this.unityConnection.connect();
|
|
71
85
|
}
|
|
@@ -124,11 +138,7 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
|
|
|
124
138
|
action: 'analyze_circular',
|
|
125
139
|
circularDependencies: [
|
|
126
140
|
{
|
|
127
|
-
cycle: [
|
|
128
|
-
'Assets/Scripts/A.cs',
|
|
129
|
-
'Assets/Scripts/B.cs',
|
|
130
|
-
'Assets/Scripts/A.cs'
|
|
131
|
-
],
|
|
141
|
+
cycle: ['Assets/Scripts/A.cs', 'Assets/Scripts/B.cs', 'Assets/Scripts/A.cs'],
|
|
132
142
|
length: 3,
|
|
133
143
|
severity: 'warning'
|
|
134
144
|
}
|
|
@@ -198,4 +208,4 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
|
|
|
198
208
|
}
|
|
199
209
|
];
|
|
200
210
|
}
|
|
201
|
-
}
|
|
211
|
+
}
|
|
@@ -71,7 +71,7 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
|
|
|
71
71
|
if (params.preset === undefined || params.preset === null) {
|
|
72
72
|
throw new Error('preset is required for apply_preset action');
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
if (params.preset === '') {
|
|
76
76
|
throw new Error('preset cannot be empty');
|
|
77
77
|
}
|
|
@@ -80,7 +80,7 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
|
|
|
80
80
|
|
|
81
81
|
async execute(params) {
|
|
82
82
|
this.validate(params);
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
if (!this.unityConnection.isConnected()) {
|
|
85
85
|
await this.unityConnection.connect();
|
|
86
86
|
}
|
|
@@ -112,8 +112,8 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
|
|
|
112
112
|
}
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
|
-
input: {
|
|
116
|
-
action: 'modify',
|
|
115
|
+
input: {
|
|
116
|
+
action: 'modify',
|
|
117
117
|
assetPath: 'Assets/Textures/icon.png',
|
|
118
118
|
settings: {
|
|
119
119
|
maxTextureSize: 1024,
|
|
@@ -136,8 +136,8 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
|
|
|
136
136
|
}
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
|
-
input: {
|
|
140
|
-
action: 'apply_preset',
|
|
139
|
+
input: {
|
|
140
|
+
action: 'apply_preset',
|
|
141
141
|
assetPath: 'Assets/Textures/icon.png',
|
|
142
142
|
preset: 'UI_Sprite'
|
|
143
143
|
},
|
|
@@ -167,4 +167,4 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
|
|
|
167
167
|
}
|
|
168
168
|
];
|
|
169
169
|
}
|
|
170
|
-
}
|
|
170
|
+
}
|
|
@@ -1,96 +1,93 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
2
|
|
|
3
3
|
export class AssetMaterialCreateToolHandler extends BaseToolHandler {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
4
|
+
constructor(unityConnection) {
|
|
5
|
+
super(
|
|
6
|
+
'asset_material_create',
|
|
7
|
+
'Create a material asset with a shader and property overrides (optional copyFrom).',
|
|
8
|
+
{
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
materialPath: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'Asset path for the material. Must start with Assets/ and end with .mat.'
|
|
14
|
+
},
|
|
15
|
+
shader: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description:
|
|
18
|
+
'Shader to use (e.g., Standard, Unlit/Color, Universal Render Pipeline/Lit).'
|
|
19
|
+
},
|
|
20
|
+
properties: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
description:
|
|
23
|
+
'Material property overrides (e.g., {"_Color":[1,0,0,1], "_Metallic":0.5}).'
|
|
24
|
+
},
|
|
25
|
+
copyFrom: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description:
|
|
28
|
+
'Optional: path to an existing material to clone before applying overrides.'
|
|
29
|
+
},
|
|
30
|
+
overwrite: {
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
description: 'If true, overwrite existing material at the path.'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
required: ['materialPath']
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
this.unityConnection = unityConnection;
|
|
39
|
+
}
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
validate(params) {
|
|
42
|
+
// Call parent validation for required fields
|
|
43
|
+
super.validate(params);
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
const { materialPath, shader, properties, copyFrom } = params;
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
// Validate materialPath format
|
|
48
|
+
if (!materialPath.startsWith('Assets/') || !materialPath.endsWith('.mat')) {
|
|
49
|
+
throw new Error('materialPath must start with Assets/ and end with .mat');
|
|
50
|
+
}
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
// Validate shader when provided
|
|
53
|
+
if (shader !== undefined && shader === '') {
|
|
54
|
+
throw new Error('shader cannot be empty when provided');
|
|
55
|
+
}
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
// Validate properties when provided
|
|
58
|
+
if (properties !== undefined) {
|
|
59
|
+
if (typeof properties !== 'object' || properties === null) {
|
|
60
|
+
throw new Error('properties must be an object');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
64
|
+
// Validate copyFrom when provided
|
|
65
|
+
if (copyFrom !== undefined) {
|
|
66
|
+
if (copyFrom === '') {
|
|
67
|
+
throw new Error('copyFrom cannot be empty when provided');
|
|
68
|
+
}
|
|
69
|
+
if (!copyFrom.startsWith('Assets/') || !copyFrom.endsWith('.mat')) {
|
|
70
|
+
throw new Error('copyFrom must be a valid material path (Assets/.../.mat)');
|
|
71
|
+
}
|
|
70
72
|
}
|
|
73
|
+
}
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
materialPath,
|
|
75
|
-
shader,
|
|
76
|
-
properties,
|
|
77
|
-
copyFrom,
|
|
78
|
-
overwrite
|
|
79
|
-
} = params;
|
|
75
|
+
async execute(params) {
|
|
76
|
+
const { materialPath, shader, properties, copyFrom, overwrite } = params;
|
|
80
77
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
// Ensure connected
|
|
79
|
+
if (!this.unityConnection.isConnected()) {
|
|
80
|
+
await this.unityConnection.connect();
|
|
81
|
+
}
|
|
85
82
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
const result = await this.unityConnection.sendCommand('create_material', {
|
|
84
|
+
materialPath,
|
|
85
|
+
shader,
|
|
86
|
+
properties,
|
|
87
|
+
copyFrom,
|
|
88
|
+
overwrite
|
|
89
|
+
});
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
96
93
|
}
|
|
@@ -1,76 +1,72 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
2
|
|
|
3
3
|
export class AssetMaterialModifyToolHandler extends BaseToolHandler {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
constructor(unityConnection) {
|
|
5
|
+
super(
|
|
6
|
+
'asset_material_modify',
|
|
7
|
+
'Modify a material by updating property values and/or changing the shader.',
|
|
8
|
+
{
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
materialPath: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'Asset path to the material. Must start with Assets/ and end with .mat.'
|
|
14
|
+
},
|
|
15
|
+
properties: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
description: 'Property updates (e.g., {"_Color":[1,0,0,1], "_Metallic":0.5}).'
|
|
18
|
+
},
|
|
19
|
+
shader: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'Optional: change the shader (e.g., Standard, Unlit/Color).'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
required: ['materialPath', 'properties']
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
this.unityConnection = unityConnection;
|
|
28
|
+
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
validate(params) {
|
|
31
|
+
// Call parent validation for required fields
|
|
32
|
+
super.validate(params);
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
const { materialPath, properties, shader } = params;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
// Validate materialPath format
|
|
37
|
+
if (!materialPath.startsWith('Assets/') || !materialPath.endsWith('.mat')) {
|
|
38
|
+
throw new Error('materialPath must start with Assets/ and end with .mat');
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
// Validate properties
|
|
42
|
+
if (typeof properties !== 'object' || properties === null || Array.isArray(properties)) {
|
|
43
|
+
throw new Error('properties must be an object');
|
|
44
|
+
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
if (Object.keys(properties).length === 0) {
|
|
47
|
+
throw new Error('properties cannot be empty');
|
|
48
|
+
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
50
|
+
// Validate shader when provided
|
|
51
|
+
if (shader !== undefined && shader === '') {
|
|
52
|
+
throw new Error('shader cannot be empty when provided');
|
|
54
53
|
}
|
|
54
|
+
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
materialPath,
|
|
59
|
-
properties,
|
|
60
|
-
shader
|
|
61
|
-
} = params;
|
|
56
|
+
async execute(params) {
|
|
57
|
+
const { materialPath, properties, shader } = params;
|
|
62
58
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
// Ensure connected
|
|
60
|
+
if (!this.unityConnection.isConnected()) {
|
|
61
|
+
await this.unityConnection.connect();
|
|
62
|
+
}
|
|
67
63
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
const result = await this.unityConnection.sendCommand('modify_material', {
|
|
65
|
+
materialPath,
|
|
66
|
+
properties,
|
|
67
|
+
shader
|
|
68
|
+
});
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
76
72
|
}
|
|
@@ -1,78 +1,75 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
2
|
|
|
3
3
|
export class AssetPrefabCreateToolHandler extends BaseToolHandler {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
4
|
+
constructor(unityConnection) {
|
|
5
|
+
super(
|
|
6
|
+
'asset_prefab_create',
|
|
7
|
+
'Create a prefab from a GameObject path or create an empty prefab at a target asset path.',
|
|
8
|
+
{
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
gameObjectPath: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description:
|
|
14
|
+
'Scene path to convert (e.g., "/Root/Player"). Mutually exclusive with createFromTemplate.'
|
|
15
|
+
},
|
|
16
|
+
prefabPath: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Asset path for the prefab. Must start with Assets/ and end with .prefab.'
|
|
19
|
+
},
|
|
20
|
+
createFromTemplate: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
description: 'If true, create an empty prefab (no source GameObject) (default: false).'
|
|
23
|
+
},
|
|
24
|
+
overwrite: {
|
|
25
|
+
type: 'boolean',
|
|
26
|
+
description:
|
|
27
|
+
'If true, overwrite existing prefab at the destination path (default: false).'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
required: ['prefabPath']
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
this.unityConnection = unityConnection;
|
|
34
|
+
}
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
validate(params) {
|
|
37
|
+
// Call parent validation for required fields
|
|
38
|
+
super.validate(params);
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
const { prefabPath, gameObjectPath, createFromTemplate } = params;
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
// Validate prefabPath format
|
|
43
|
+
if (!prefabPath.startsWith('Assets/') || !prefabPath.endsWith('.prefab')) {
|
|
44
|
+
throw new Error('prefabPath must start with Assets/ and end with .prefab');
|
|
45
|
+
}
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
// Validate gameObjectPath when provided
|
|
48
|
+
if (gameObjectPath !== undefined && gameObjectPath === '') {
|
|
49
|
+
throw new Error('gameObjectPath cannot be empty when provided');
|
|
50
|
+
}
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
52
|
+
// Validate mutually exclusive options
|
|
53
|
+
if (gameObjectPath && createFromTemplate) {
|
|
54
|
+
throw new Error('Cannot specify both gameObjectPath and createFromTemplate');
|
|
54
55
|
}
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
gameObjectPath,
|
|
59
|
-
prefabPath,
|
|
60
|
-
createFromTemplate = false,
|
|
61
|
-
overwrite = false
|
|
62
|
-
} = params;
|
|
58
|
+
async execute(params) {
|
|
59
|
+
const { gameObjectPath, prefabPath, createFromTemplate = false, overwrite = false } = params;
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
// Ensure connected
|
|
62
|
+
if (!this.unityConnection.isConnected()) {
|
|
63
|
+
await this.unityConnection.connect();
|
|
64
|
+
}
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
const result = await this.unityConnection.sendCommand('create_prefab', {
|
|
67
|
+
gameObjectPath,
|
|
68
|
+
prefabPath,
|
|
69
|
+
createFromTemplate,
|
|
70
|
+
overwrite
|
|
71
|
+
});
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
78
75
|
}
|