File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
UnityMcpBridge/Editor/Helpers Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ using UnityEditor ;
2+ using UnityEngine ;
3+
4+ namespace UnityMcpBridge . Editor . Helpers
5+ {
6+ /// <summary>
7+ /// Handles automatic installation of the Python server when the package is first installed.
8+ /// </summary>
9+ [ InitializeOnLoad ]
10+ public static class PackageInstaller
11+ {
12+ private const string InstallationFlagKey = "UnityMCP.ServerInstalled" ;
13+
14+ static PackageInstaller ( )
15+ {
16+ // Check if this is the first time the package is loaded
17+ if ( ! EditorPrefs . GetBool ( InstallationFlagKey , false ) )
18+ {
19+ // Schedule the installation for after Unity is fully loaded
20+ EditorApplication . delayCall += InstallServerOnFirstLoad ;
21+ }
22+ }
23+
24+ private static void InstallServerOnFirstLoad ( )
25+ {
26+ try
27+ {
28+ Debug . Log ( "Unity MCP: Installing Python server..." ) ;
29+ ServerInstaller . EnsureServerInstalled ( ) ;
30+
31+ // Mark as installed
32+ EditorPrefs . SetBool ( InstallationFlagKey , true ) ;
33+
34+ Debug . Log ( "Unity MCP: Python server installation completed successfully." ) ;
35+ }
36+ catch ( System . Exception ex )
37+ {
38+ Debug . LogError ( $ "Unity MCP: Failed to install Python server: { ex . Message } ") ;
39+ Debug . LogWarning ( "Unity MCP: You may need to manually install the Python server. Check the Unity MCP Editor Window for instructions." ) ;
40+ }
41+ }
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments