@@ -37,17 +37,11 @@ private string GetCompilerPath(List<string> arguments)
3737 return result ;
3838 }
3939
40- private string GetCompilerPathEx ( List < string > arguments )
40+ private string GetUniversalCompilerPath ( )
4141 {
4242 var basePath = Path . Combine ( Directory . GetCurrentDirectory ( ) , "Compiler" ) ;
4343 var compilerPath = Path . Combine ( basePath , "UniversalCompiler.exe" ) ;
44- if ( File . Exists ( compilerPath ) )
45- {
46- return compilerPath ;
47- }
48-
49- Debug . LogWarning ( $ "Custom C# compiler not found in project directory ({ compilerPath } ), using the default compiler") ;
50- return GetCompilerPath ( arguments ) ;
44+ return File . Exists ( compilerPath ) ? compilerPath : null ;
5145 }
5246
5347 // Copy of MonoCSharpCompiler.StartCompiler()
@@ -61,9 +55,6 @@ protected override Program StartCompiler()
6155 "-target:library" ,
6256 "-nowarn:0169" ,
6357 "-out:" + PrepareFileName ( _island . _output ) ,
64- "-unsafe" ,
65- "-define:__UNITY_PROCESSID__" + System . Diagnostics . Process . GetCurrentProcess ( ) . Id ,
66- "-define:__UNITY_PROFILE__" + Path . GetFileName ( base . GetProfileDirectory ( ) ) . Replace ( "." , "_" )
6758 } ;
6859 foreach ( var reference in _island . _references )
6960 {
@@ -90,6 +81,23 @@ protected override Program StartCompiler()
9081 }
9182 }
9283
93- return StartCompiler ( _island . _target , GetCompilerPathEx ( arguments ) , arguments ) ;
84+ var universalCompilerPath = GetUniversalCompilerPath ( ) ;
85+ if ( universalCompilerPath != null )
86+ {
87+ // use universal compiler.
88+ var defaultCompilerName = Path . GetFileNameWithoutExtension ( GetCompilerPath ( arguments ) ) ;
89+ arguments . Add ( "-define:__UNITY_PROCESSID__" + System . Diagnostics . Process . GetCurrentProcess ( ) . Id ) ;
90+ arguments . Add ( "-define:__UNITY_PROFILE__" + Path . GetFileName ( base . GetProfileDirectory ( ) ) . Replace ( "." , "_" ) ) ;
91+ var rspFileName = "Assets/" + defaultCompilerName + ".rsp" ;
92+ if ( File . Exists ( rspFileName ) )
93+ arguments . Add ( "@" + rspFileName ) ;
94+ return StartCompiler ( _island . _target , universalCompilerPath , arguments ) ;
95+ }
96+ else
97+ {
98+ // fallback to the default compiler.
99+ Debug . LogWarning ( $ "Universal C# compiler not found in project directory. Use the default compiler") ;
100+ return StartCompiler ( _island . _target , GetCompilerPath ( arguments ) , arguments ) ;
101+ }
94102 }
95103}
0 commit comments