@@ -46,13 +46,9 @@ public static void WebGL_Dev()
4646
4747 // Default dev output (existing behavior)
4848 string buildPath = Path . Combine ( ".." , ".." , "WebSites" , "SpaceCraft" ) ;
49- // Allow CI override via env var
50- var envOut = Environment . GetEnvironmentVariable ( "SC_BUILD_OUTPUT" ) ;
51- if ( ! string . IsNullOrEmpty ( envOut ) )
52- {
53- buildPath = envOut ;
54- Debug . Log ( $ "[Build] Overriding output via SC_BUILD_OUTPUT => { buildPath } ") ;
55- }
49+ // Allow CI override via env var or CLI
50+ buildPath = ResolveOutputPath ( buildPath ) ;
51+ Debug . Log ( $ "[Build] Output path: { buildPath } ") ;
5652
5753 BuildPlayerOptions options = new BuildPlayerOptions
5854 {
@@ -95,13 +91,9 @@ public static void WebGL_Prod()
9591
9692 // Default prod output (existing behavior)
9793 string buildPath = Path . Combine ( "Builds" , "SpaceCraft" ) ;
98- // Allow CI override via env var
99- var envOut = Environment . GetEnvironmentVariable ( "SC_BUILD_OUTPUT" ) ;
100- if ( ! string . IsNullOrEmpty ( envOut ) )
101- {
102- buildPath = envOut ;
103- Debug . Log ( $ "[Build] Overriding output via SC_BUILD_OUTPUT => { buildPath } ") ;
104- }
94+ // Allow CI override via env var or CLI
95+ buildPath = ResolveOutputPath ( buildPath ) ;
96+ Debug . Log ( $ "[Build] Output path: { buildPath } ") ;
10597
10698 BuildPlayerOptions options = new BuildPlayerOptions
10799 {
@@ -247,6 +239,29 @@ private static string[] GetBuildScenes()
247239 return scenes ;
248240 }
249241
242+ private static string ResolveOutputPath ( string defaultPath )
243+ {
244+ // 1) Environment variable
245+ var envOut = Environment . GetEnvironmentVariable ( "SC_BUILD_OUTPUT" ) ;
246+ if ( ! string . IsNullOrEmpty ( envOut ) ) return envOut ;
247+
248+ // 2) Command line arg: -scOut <path> or --scOut=<path>
249+ var args = Environment . GetCommandLineArgs ( ) ;
250+ for ( int i = 0 ; i < args . Length ; i ++ )
251+ {
252+ if ( args [ i ] == "-scOut" && i + 1 < args . Length )
253+ {
254+ return args [ i + 1 ] ;
255+ }
256+ if ( args [ i ] . StartsWith ( "--scOut=" ) )
257+ {
258+ var val = args [ i ] . Substring ( "--scOut=" . Length ) ;
259+ if ( ! string . IsNullOrEmpty ( val ) ) return val ;
260+ }
261+ }
262+ return defaultPath ;
263+ }
264+
250265 private static bool IsCommandLineBuild ( )
251266 {
252267 return Environment . CommandLine . Contains ( "-batchmode" ) ;
0 commit comments