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.
Files changed (61) hide show
  1. cli/commands/animation.py +6 -9
  2. cli/commands/asset.py +50 -80
  3. cli/commands/audio.py +14 -22
  4. cli/commands/batch.py +20 -33
  5. cli/commands/code.py +63 -70
  6. cli/commands/component.py +33 -55
  7. cli/commands/editor.py +122 -188
  8. cli/commands/gameobject.py +60 -83
  9. cli/commands/instance.py +28 -36
  10. cli/commands/lighting.py +54 -59
  11. cli/commands/material.py +39 -68
  12. cli/commands/prefab.py +63 -81
  13. cli/commands/scene.py +30 -54
  14. cli/commands/script.py +32 -50
  15. cli/commands/shader.py +43 -55
  16. cli/commands/texture.py +53 -51
  17. cli/commands/tool.py +24 -27
  18. cli/commands/ui.py +125 -130
  19. cli/commands/vfx.py +84 -138
  20. cli/utils/confirmation.py +37 -0
  21. cli/utils/connection.py +32 -2
  22. cli/utils/constants.py +23 -0
  23. cli/utils/parsers.py +112 -0
  24. core/config.py +0 -4
  25. core/telemetry.py +20 -2
  26. {mcpforunityserver-9.3.0b20260128055651.dist-info → mcpforunityserver-9.3.0b20260129121506.dist-info}/METADATA +21 -1
  27. mcpforunityserver-9.3.0b20260129121506.dist-info/RECORD +103 -0
  28. services/resources/active_tool.py +1 -1
  29. services/resources/custom_tools.py +1 -1
  30. services/resources/editor_state.py +1 -1
  31. services/resources/gameobject.py +4 -4
  32. services/resources/layers.py +1 -1
  33. services/resources/menu_items.py +1 -1
  34. services/resources/prefab.py +3 -3
  35. services/resources/prefab_stage.py +1 -1
  36. services/resources/project_info.py +1 -1
  37. services/resources/selection.py +1 -1
  38. services/resources/tags.py +1 -1
  39. services/resources/tests.py +40 -8
  40. services/resources/unity_instances.py +1 -1
  41. services/resources/windows.py +1 -1
  42. services/tools/__init__.py +3 -1
  43. services/tools/find_gameobjects.py +32 -11
  44. services/tools/manage_gameobject.py +11 -66
  45. services/tools/manage_material.py +4 -37
  46. services/tools/manage_prefabs.py +51 -7
  47. services/tools/manage_script.py +1 -1
  48. services/tools/manage_texture.py +10 -96
  49. services/tools/run_tests.py +67 -4
  50. services/tools/utils.py +217 -0
  51. transport/models.py +1 -0
  52. transport/plugin_hub.py +2 -1
  53. transport/plugin_registry.py +3 -0
  54. transport/unity_transport.py +0 -51
  55. utils/focus_nudge.py +291 -23
  56. mcpforunityserver-9.3.0b20260128055651.dist-info/RECORD +0 -101
  57. utils/reload_sentinel.py +0 -9
  58. {mcpforunityserver-9.3.0b20260128055651.dist-info → mcpforunityserver-9.3.0b20260129121506.dist-info}/WHEEL +0 -0
  59. {mcpforunityserver-9.3.0b20260128055651.dist-info → mcpforunityserver-9.3.0b20260129121506.dist-info}/entry_points.txt +0 -0
  60. {mcpforunityserver-9.3.0b20260128055651.dist-info → mcpforunityserver-9.3.0b20260129121506.dist-info}/licenses/LICENSE +0 -0
  61. {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, UnityConnectionError
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
- try:
38
- # Step 1: Create empty GameObject
39
- result = run_command("manage_gameobject", {
40
- "action": "create",
41
- "name": name,
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
- 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
- for component in ["Canvas", "CanvasScaler", "GraphicRaycaster"]:
50
- run_command("manage_components", {
51
- "action": "add",
52
- "target": name,
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": "Canvas",
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
- click.echo(format_output(result, config.format))
68
- print_success(f"Created Canvas: {name}")
69
- except UnityConnectionError as e:
70
- print_error(str(e))
71
- sys.exit(1)
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
- try:
103
- # Step 1: Create empty GameObject with parent
104
- result = run_command("manage_gameobject", {
105
- "action": "create",
106
- "name": name,
107
- "parent": parent,
108
- "position": list(position),
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
- if not (result.get("success") or result.get("data") or result.get("result")):
112
- click.echo(format_output(result, config.format))
113
- return
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
- # Step 2: Add RectTransform and TextMeshProUGUI
116
- run_command("manage_components", {
117
- "action": "add",
118
- "target": name,
119
- "componentType": "TextMeshProUGUI",
120
- }, config)
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
- # Step 3: Set text content
123
- run_command("manage_components", {
124
- "action": "set_property",
125
- "target": name,
126
- "componentType": "TextMeshProUGUI",
127
- "property": "text",
128
- "value": text,
129
- }, config)
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
- click.echo(format_output(result, config.format))
132
- print_success(f"Created Text: {name}")
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
- try:
160
- # Step 1: Create empty GameObject with parent
161
- result = run_command("manage_gameobject", {
162
- "action": "create",
163
- "name": name,
164
- "parent": parent,
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
- if not (result.get("success") or result.get("data") or result.get("result")):
168
- click.echo(format_output(result, config.format))
169
- return
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
- # Step 4: Add TextMeshProUGUI to label and set text
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": label_name,
191
- "componentType": "TextMeshProUGUI",
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
- click.echo(format_output(result, config.format))
202
- print_success(f"Created Button: {name} (with label '{text}')")
203
- except UnityConnectionError as e:
204
- print_error(str(e))
205
- sys.exit(1)
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
- try:
231
- # Step 1: Create empty GameObject with parent
232
- result = run_command("manage_gameobject", {
233
- "action": "create",
234
- "name": name,
235
- "parent": parent,
236
- }, config)
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
- if not (result.get("success") or result.get("data") or result.get("result")):
239
- click.echo(format_output(result, config.format))
240
- return
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
- # Step 2: Add Image component
247
+ # Step 3: Set sprite if provided
248
+ if sprite:
243
249
  run_command("manage_components", {
244
- "action": "add",
250
+ "action": "set_property",
245
251
  "target": name,
246
252
  "componentType": "Image",
253
+ "property": "sprite",
254
+ "value": sprite,
247
255
  }, config)
248
256
 
249
- # Step 3: Set sprite if provided
250
- if sprite:
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}")