MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / HubService

Class HubService

unity_cli/hub/service.py:18–118  ·  view source on GitHub ↗

High-level service for Unity Hub operations.

Source from the content-addressed store, hash-verified

16
17
18class HubService:
19 """High-level service for Unity Hub operations."""
20
21 def open_project(
22 self,
23 project_path: Path,
24 editor_override: str | None = None,
25 non_interactive: bool = False,
26 wait: bool = False,
27 ) -> bool:
28 """Open a Unity project with the appropriate editor.
29
30 Flow:
31 1. Validate project path
32 2. Read ProjectVersion.txt to get required version
33 3. Find matching installed editor
34 4. If not found, prompt user (or fail in non-interactive mode)
35 5. Launch editor
36
37 Args:
38 project_path: Path to Unity project.
39 editor_override: Override editor version (skip version detection).
40 non_interactive: If True, fail instead of prompting.
41 wait: If True, wait for editor to close.
42
43 Returns:
44 True if editor was launched successfully.
45
46 Raises:
47 ProjectError: If project path is invalid.
48 EditorNotFoundError: If required editor not installed and can't resolve.
49 """
50 project_path = project_path.resolve()
51
52 if not is_unity_project(project_path):
53 raise ProjectError(
54 f"Not a valid Unity project: {project_path}",
55 code="INVALID_PROJECT",
56 )
57
58 # Determine required version
59 if editor_override:
60 required_version = editor_override
61 else:
62 project_version = ProjectVersion.from_file(project_path)
63 required_version = project_version.version
64
65 # Resolve editor
66 editor = self.resolve_editor(
67 required_version=required_version,
68 non_interactive=non_interactive,
69 )
70
71 if editor is None:
72 raise EditorNotFoundError(
73 f"Unity {required_version} is not installed and no alternative selected",
74 code="EDITOR_NOT_RESOLVED",
75 )

Callers 1

open_projectFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected