mcpforunityserver 9.3.0b20260128055651__py3-none-any.whl → 9.3.0b20260129121506__py3-none-any.whl
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.
- cli/commands/animation.py +6 -9
- cli/commands/asset.py +50 -80
- cli/commands/audio.py +14 -22
- cli/commands/batch.py +20 -33
- cli/commands/code.py +63 -70
- cli/commands/component.py +33 -55
- cli/commands/editor.py +122 -188
- cli/commands/gameobject.py +60 -83
- cli/commands/instance.py +28 -36
- cli/commands/lighting.py +54 -59
- cli/commands/material.py +39 -68
- cli/commands/prefab.py +63 -81
- cli/commands/scene.py +30 -54
- cli/commands/script.py +32 -50
- cli/commands/shader.py +43 -55
- cli/commands/texture.py +53 -51
- cli/commands/tool.py +24 -27
- cli/commands/ui.py +125 -130
- cli/commands/vfx.py +84 -138
- cli/utils/confirmation.py +37 -0
- cli/utils/connection.py +32 -2
- cli/utils/constants.py +23 -0
- cli/utils/parsers.py +112 -0
- core/config.py +0 -4
- core/telemetry.py +20 -2
- {mcpforunityserver-9.3.0b20260128055651.dist-info → mcpforunityserver-9.3.0b20260129121506.dist-info}/METADATA +21 -1
- mcpforunityserver-9.3.0b20260129121506.dist-info/RECORD +103 -0
- services/resources/active_tool.py +1 -1
- services/resources/custom_tools.py +1 -1
- services/resources/editor_state.py +1 -1
- services/resources/gameobject.py +4 -4
- services/resources/layers.py +1 -1
- services/resources/menu_items.py +1 -1
- services/resources/prefab.py +3 -3
- services/resources/prefab_stage.py +1 -1
- services/resources/project_info.py +1 -1
- services/resources/selection.py +1 -1
- services/resources/tags.py +1 -1
- services/resources/tests.py +40 -8
- services/resources/unity_instances.py +1 -1
- services/resources/windows.py +1 -1
- services/tools/__init__.py +3 -1
- services/tools/find_gameobjects.py +32 -11
- services/tools/manage_gameobject.py +11 -66
- services/tools/manage_material.py +4 -37
- services/tools/manage_prefabs.py +51 -7
- services/tools/manage_script.py +1 -1
- services/tools/manage_texture.py +10 -96
- services/tools/run_tests.py +67 -4
- services/tools/utils.py +217 -0
- transport/models.py +1 -0
- transport/plugin_hub.py +2 -1
- transport/plugin_registry.py +3 -0
- transport/unity_transport.py +0 -51
- utils/focus_nudge.py +291 -23
- mcpforunityserver-9.3.0b20260128055651.dist-info/RECORD +0 -101
- utils/reload_sentinel.py +0 -9
- {mcpforunityserver-9.3.0b20260128055651.dist-info → mcpforunityserver-9.3.0b20260129121506.dist-info}/WHEEL +0 -0
- {mcpforunityserver-9.3.0b20260128055651.dist-info → mcpforunityserver-9.3.0b20260129121506.dist-info}/entry_points.txt +0 -0
- {mcpforunityserver-9.3.0b20260128055651.dist-info → mcpforunityserver-9.3.0b20260129121506.dist-info}/licenses/LICENSE +0 -0
- {mcpforunityserver-9.3.0b20260128055651.dist-info → mcpforunityserver-9.3.0b20260129121506.dist-info}/top_level.txt +0 -0
cli/commands/ui.py
CHANGED
|
@@ -6,7 +6,7 @@ from typing import Optional, Any
|
|
|
6
6
|
|
|
7
7
|
from cli.utils.config import get_config
|
|
8
8
|
from cli.utils.output import format_output, print_error, print_success
|
|
9
|
-
from cli.utils.connection import run_command,
|
|
9
|
+
from cli.utils.connection import run_command, handle_unity_errors
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@click.group()
|
|
@@ -24,6 +24,7 @@ def ui():
|
|
|
24
24
|
default="ScreenSpaceOverlay",
|
|
25
25
|
help="Canvas render mode."
|
|
26
26
|
)
|
|
27
|
+
@handle_unity_errors
|
|
27
28
|
def create_canvas(name: str, render_mode: str):
|
|
28
29
|
"""Create a new Canvas.
|
|
29
30
|
|
|
@@ -34,41 +35,44 @@ def create_canvas(name: str, render_mode: str):
|
|
|
34
35
|
"""
|
|
35
36
|
config = get_config()
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, config)
|
|
38
|
+
# Step 1: Create empty GameObject
|
|
39
|
+
result = run_command("manage_gameobject", {
|
|
40
|
+
"action": "create",
|
|
41
|
+
"name": name,
|
|
42
|
+
}, config)
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"componentType": component,
|
|
54
|
-
}, config)
|
|
55
|
-
|
|
56
|
-
# Step 3: Set render mode
|
|
57
|
-
render_mode_value = {"ScreenSpaceOverlay": 0,
|
|
58
|
-
"ScreenSpaceCamera": 1, "WorldSpace": 2}.get(render_mode, 0)
|
|
59
|
-
run_command("manage_components", {
|
|
60
|
-
"action": "set_property",
|
|
44
|
+
if not (result.get("success") or result.get("data") or result.get("result")):
|
|
45
|
+
click.echo(format_output(result, config.format))
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
# Step 2: Add Canvas components
|
|
49
|
+
failed_components = []
|
|
50
|
+
for component in ["Canvas", "CanvasScaler", "GraphicRaycaster"]:
|
|
51
|
+
comp_result = run_command("manage_components", {
|
|
52
|
+
"action": "add",
|
|
61
53
|
"target": name,
|
|
62
|
-
"componentType":
|
|
63
|
-
"property": "renderMode",
|
|
64
|
-
"value": render_mode_value,
|
|
54
|
+
"componentType": component,
|
|
65
55
|
}, config)
|
|
56
|
+
if not (comp_result.get("success") or comp_result.get("data")):
|
|
57
|
+
failed_components.append((component, comp_result.get("error", "Unknown error")))
|
|
66
58
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
if failed_components:
|
|
60
|
+
error_details = "; ".join([f"{c}: {e}" for c, e in failed_components])
|
|
61
|
+
print_error(f"Failed to add components: {error_details}")
|
|
62
|
+
|
|
63
|
+
# Step 3: Set render mode
|
|
64
|
+
render_mode_value = {"ScreenSpaceOverlay": 0,
|
|
65
|
+
"ScreenSpaceCamera": 1, "WorldSpace": 2}.get(render_mode, 0)
|
|
66
|
+
run_command("manage_components", {
|
|
67
|
+
"action": "set_property",
|
|
68
|
+
"target": name,
|
|
69
|
+
"componentType": "Canvas",
|
|
70
|
+
"property": "renderMode",
|
|
71
|
+
"value": render_mode_value,
|
|
72
|
+
}, config)
|
|
73
|
+
|
|
74
|
+
click.echo(format_output(result, config.format))
|
|
75
|
+
print_success(f"Created Canvas: {name}")
|
|
72
76
|
|
|
73
77
|
|
|
74
78
|
@ui.command("create-text")
|
|
@@ -90,6 +94,7 @@ def create_canvas(name: str, render_mode: str):
|
|
|
90
94
|
default=(0, 0),
|
|
91
95
|
help="Anchored position X Y."
|
|
92
96
|
)
|
|
97
|
+
@handle_unity_errors
|
|
93
98
|
def create_text(name: str, parent: str, text: str, position: tuple):
|
|
94
99
|
"""Create a UI Text element (TextMeshPro).
|
|
95
100
|
|
|
@@ -99,40 +104,36 @@ def create_text(name: str, parent: str, text: str, position: tuple):
|
|
|
99
104
|
"""
|
|
100
105
|
config = get_config()
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}, config)
|
|
107
|
+
# Step 1: Create empty GameObject with parent
|
|
108
|
+
result = run_command("manage_gameobject", {
|
|
109
|
+
"action": "create",
|
|
110
|
+
"name": name,
|
|
111
|
+
"parent": parent,
|
|
112
|
+
"position": list(position),
|
|
113
|
+
}, config)
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
if not (result.get("success") or result.get("data") or result.get("result")):
|
|
116
|
+
click.echo(format_output(result, config.format))
|
|
117
|
+
return
|
|
114
118
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
# Step 2: Add RectTransform and TextMeshProUGUI
|
|
120
|
+
run_command("manage_components", {
|
|
121
|
+
"action": "add",
|
|
122
|
+
"target": name,
|
|
123
|
+
"componentType": "TextMeshProUGUI",
|
|
124
|
+
}, config)
|
|
121
125
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
# Step 3: Set text content
|
|
127
|
+
run_command("manage_components", {
|
|
128
|
+
"action": "set_property",
|
|
129
|
+
"target": name,
|
|
130
|
+
"componentType": "TextMeshProUGUI",
|
|
131
|
+
"property": "text",
|
|
132
|
+
"value": text,
|
|
133
|
+
}, config)
|
|
130
134
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
except UnityConnectionError as e:
|
|
134
|
-
print_error(str(e))
|
|
135
|
-
sys.exit(1)
|
|
135
|
+
click.echo(format_output(result, config.format))
|
|
136
|
+
print_success(f"Created Text: {name}")
|
|
136
137
|
|
|
137
138
|
|
|
138
139
|
@ui.command("create-button")
|
|
@@ -147,6 +148,7 @@ def create_text(name: str, parent: str, text: str, position: tuple):
|
|
|
147
148
|
default="Button",
|
|
148
149
|
help="Button label text."
|
|
149
150
|
)
|
|
151
|
+
@handle_unity_errors
|
|
150
152
|
def create_button(name: str, parent: str, text: str): # text current placeholder
|
|
151
153
|
"""Create a UI Button.
|
|
152
154
|
|
|
@@ -156,53 +158,49 @@ def create_button(name: str, parent: str, text: str): # text current placeholde
|
|
|
156
158
|
"""
|
|
157
159
|
config = get_config()
|
|
158
160
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}, config)
|
|
161
|
+
# Step 1: Create empty GameObject with parent
|
|
162
|
+
result = run_command("manage_gameobject", {
|
|
163
|
+
"action": "create",
|
|
164
|
+
"name": name,
|
|
165
|
+
"parent": parent,
|
|
166
|
+
}, config)
|
|
166
167
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
# Step 2: Add Button and Image components
|
|
172
|
-
for component in ["Image", "Button"]:
|
|
173
|
-
run_command("manage_components", {
|
|
174
|
-
"action": "add",
|
|
175
|
-
"target": name,
|
|
176
|
-
"componentType": component,
|
|
177
|
-
}, config)
|
|
178
|
-
|
|
179
|
-
# Step 3: Create child label GameObject
|
|
180
|
-
label_name = f"{name}_Label"
|
|
181
|
-
label_result = run_command("manage_gameobject", {
|
|
182
|
-
"action": "create",
|
|
183
|
-
"name": label_name,
|
|
184
|
-
"parent": name,
|
|
185
|
-
}, config)
|
|
168
|
+
if not (result.get("success") or result.get("data") or result.get("result")):
|
|
169
|
+
click.echo(format_output(result, config.format))
|
|
170
|
+
return
|
|
186
171
|
|
|
187
|
-
|
|
172
|
+
# Step 2: Add Button and Image components
|
|
173
|
+
for component in ["Image", "Button"]:
|
|
188
174
|
run_command("manage_components", {
|
|
189
175
|
"action": "add",
|
|
190
|
-
"target":
|
|
191
|
-
"componentType":
|
|
192
|
-
}, config)
|
|
193
|
-
run_command("manage_components", {
|
|
194
|
-
"action": "set_property",
|
|
195
|
-
"target": label_name,
|
|
196
|
-
"componentType": "TextMeshProUGUI",
|
|
197
|
-
"property": "text",
|
|
198
|
-
"value": text,
|
|
176
|
+
"target": name,
|
|
177
|
+
"componentType": component,
|
|
199
178
|
}, config)
|
|
200
179
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
180
|
+
# Step 3: Create child label GameObject
|
|
181
|
+
label_name = f"{name}_Label"
|
|
182
|
+
run_command("manage_gameobject", {
|
|
183
|
+
"action": "create",
|
|
184
|
+
"name": label_name,
|
|
185
|
+
"parent": name,
|
|
186
|
+
}, config)
|
|
187
|
+
|
|
188
|
+
# Step 4: Add TextMeshProUGUI to label and set text
|
|
189
|
+
run_command("manage_components", {
|
|
190
|
+
"action": "add",
|
|
191
|
+
"target": label_name,
|
|
192
|
+
"componentType": "TextMeshProUGUI",
|
|
193
|
+
}, config)
|
|
194
|
+
run_command("manage_components", {
|
|
195
|
+
"action": "set_property",
|
|
196
|
+
"target": label_name,
|
|
197
|
+
"componentType": "TextMeshProUGUI",
|
|
198
|
+
"property": "text",
|
|
199
|
+
"value": text,
|
|
200
|
+
}, config)
|
|
201
|
+
|
|
202
|
+
click.echo(format_output(result, config.format))
|
|
203
|
+
print_success(f"Created Button: {name} (with label '{text}')")
|
|
206
204
|
|
|
207
205
|
|
|
208
206
|
@ui.command("create-image")
|
|
@@ -217,6 +215,7 @@ def create_button(name: str, parent: str, text: str): # text current placeholde
|
|
|
217
215
|
default=None,
|
|
218
216
|
help="Sprite asset path."
|
|
219
217
|
)
|
|
218
|
+
@handle_unity_errors
|
|
220
219
|
def create_image(name: str, parent: str, sprite: Optional[str]):
|
|
221
220
|
"""Create a UI Image.
|
|
222
221
|
|
|
@@ -227,37 +226,33 @@ def create_image(name: str, parent: str, sprite: Optional[str]):
|
|
|
227
226
|
"""
|
|
228
227
|
config = get_config()
|
|
229
228
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
229
|
+
# Step 1: Create empty GameObject with parent
|
|
230
|
+
result = run_command("manage_gameobject", {
|
|
231
|
+
"action": "create",
|
|
232
|
+
"name": name,
|
|
233
|
+
"parent": parent,
|
|
234
|
+
}, config)
|
|
235
|
+
|
|
236
|
+
if not (result.get("success") or result.get("data") or result.get("result")):
|
|
237
|
+
click.echo(format_output(result, config.format))
|
|
238
|
+
return
|
|
237
239
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
240
|
+
# Step 2: Add Image component
|
|
241
|
+
run_command("manage_components", {
|
|
242
|
+
"action": "add",
|
|
243
|
+
"target": name,
|
|
244
|
+
"componentType": "Image",
|
|
245
|
+
}, config)
|
|
241
246
|
|
|
242
|
-
|
|
247
|
+
# Step 3: Set sprite if provided
|
|
248
|
+
if sprite:
|
|
243
249
|
run_command("manage_components", {
|
|
244
|
-
"action": "
|
|
250
|
+
"action": "set_property",
|
|
245
251
|
"target": name,
|
|
246
252
|
"componentType": "Image",
|
|
253
|
+
"property": "sprite",
|
|
254
|
+
"value": sprite,
|
|
247
255
|
}, config)
|
|
248
256
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
run_command("manage_components", {
|
|
252
|
-
"action": "set_property",
|
|
253
|
-
"target": name,
|
|
254
|
-
"componentType": "Image",
|
|
255
|
-
"property": "sprite",
|
|
256
|
-
"value": sprite,
|
|
257
|
-
}, config)
|
|
258
|
-
|
|
259
|
-
click.echo(format_output(result, config.format))
|
|
260
|
-
print_success(f"Created Image: {name}")
|
|
261
|
-
except UnityConnectionError as e:
|
|
262
|
-
print_error(str(e))
|
|
263
|
-
sys.exit(1)
|
|
257
|
+
click.echo(format_output(result, config.format))
|
|
258
|
+
print_success(f"Created Image: {name}")
|