File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -110,12 +110,32 @@ public void SaveSettings()
110110 // see: https://learn.microsoft.com/en-us/dotnet/api/system.environmentvariabletarget?view=net-8.0#remarks
111111 Environment . SetEnvironmentVariable ( EnvUnityPort , Port . ToString ( ) , EnvironmentVariableTarget . Process ) ;
112112 Environment . SetEnvironmentVariable ( EnvUnityRequestTimeout , RequestTimeoutSeconds . ToString ( ) , EnvironmentVariableTarget . Process ) ;
113+
114+ // For non w32 systems.
115+ SaveSettingsToNodeServer ( ) ;
113116 }
114117 catch ( Exception ex )
115118 {
116119 // Can't use LoggerService here as it might create circular dependency
117120 Debug . LogError ( $ "[MCP Unity] Failed to save settings: { ex . Message } ") ;
118121 }
119122 }
123+
124+
125+ public void SaveSettingsToNodeServer ( ) {
126+ try
127+ {
128+ string propertiesPath = GetServerPath ( ) + "/build/server.env" ;
129+ using ( var writer = new StreamWriter ( propertiesPath , false ) )
130+ {
131+ writer . WriteLine ( $ "{ EnvUnityPort } ={ Port } ") ;
132+ writer . WriteLine ( $ "{ EnvUnityRequestTimeout } ={ RequestTimeoutSeconds } ") ;
133+ }
134+ }
135+ catch ( Exception ex )
136+ {
137+ Debug . LogError ( $ "[MCP Unity] Failed to write server env properties: { ex . Message } ") ;
138+ }
139+ }
120140 }
121141}
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public static string GenerateMcpConfigJson(bool useTabsIndentation)
6060 }
6161
6262 /// <summary>
63- /// Gets the absolute path to the Server directory containing package.json
63+ /// Gets the absolute path to the Server directory containing package.json (root server dir).
6464 /// Works whether MCP Unity is installed via Package Manager or directly in the Assets folder
6565 /// </summary>
6666 public static string GetServerPath ( )
You can’t perform that action at this time.
0 commit comments