@@ -151,7 +151,7 @@ export class UnityEditor {
151151 */
152152 public async Run ( command : EditorCommand ) : Promise < void > {
153153 let isCancelled = false ;
154- let exitCode : number = 1 ;
154+ let exitCode : number | undefined = undefined ;
155155 let procInfo : ProcInfo | null = null ;
156156 let logTail : LogTailResult | null = null ;
157157 let unityProcess : ChildProcessByStdio < null , null , null > ;
@@ -196,6 +196,7 @@ export class UnityEditor {
196196 }
197197
198198 const logPath : string = GetArgumentValueAsString ( '-logFile' , command . args ) ;
199+ logTail = TailLogFile ( logPath ) ;
199200 const commandStr = `\x1b[34m${ this . editorPath } ${ command . args . join ( ' ' ) } \x1b[0m` ;
200201 this . logger . startGroup ( commandStr ) ;
201202
@@ -211,6 +212,13 @@ export class UnityEditor {
211212 }
212213 } ) ;
213214 } else {
215+ if ( process . platform === 'darwin' ) {
216+ if ( this . version . architecture === 'X86_64' && process . arch === 'arm64' ) {
217+ // Force the Unity Editor to run under Rosetta 2 on Apple Silicon Macs if the editor is x86_64
218+ command . args . unshift ( 'arch' , '-x86_64' ) ;
219+ }
220+ }
221+
214222 unityProcess = spawn (
215223 this . editorPath ,
216224 command . args , {
@@ -230,14 +238,13 @@ export class UnityEditor {
230238 process . once ( 'SIGTERM' , onCancel ) ;
231239 procInfo = { pid : unityProcess . pid , ppid : process . pid , name : this . editorPath } ;
232240 this . logger . debug ( `Unity process started with pid: ${ procInfo . pid } ` ) ;
233- await WaitForFileToBeCreatedAndReadable ( logPath , 10_000 ) ;
234- logTail = TailLogFile ( logPath ) ;
235241 exitCode = await new Promise ( ( resolve , reject ) => {
236242 unityProcess . on ( 'close' , ( code ) => {
237243 logTail ?. stopLogTail ( ) ;
238244 resolve ( code === null ? 1 : code ) ;
239245 } ) ;
240246 unityProcess . on ( 'error' , ( error ) => {
247+ this . logger . error ( `Unity process error: ${ error } ` ) ;
241248 logTail ?. stopLogTail ( ) ;
242249 reject ( error ) ;
243250 } ) ;
@@ -258,7 +265,9 @@ export class UnityEditor {
258265 if ( ! isCancelled ) {
259266 await tryKillEditorProcesses ( ) ;
260267
261- if ( exitCode !== 0 ) {
268+ if ( exitCode === undefined ) {
269+ throw Error ( 'Failed to start Unity!' ) ;
270+ } else if ( exitCode > 0 ) {
262271 throw Error ( `Unity failed with exit code ${ exitCode } ` ) ;
263272 }
264273 }
0 commit comments