@@ -17,6 +17,119 @@ public class InMemoryCompilationBindingCallback : IBindingCallback, ICodeGenCall
1717 private List < Assembly > _generatedAssemblies = new List < Assembly > ( ) ;
1818 private string _compilerOptions ;
1919
20+ public static List < string > GetDefinedSymbols ( )
21+ {
22+ var defines = new List < string > ( ) ;
23+
24+ #if UNITY_EDITOR // #define directive to call Unity Editor scripts from your game code.
25+ defines . Add ( "UNITY_EDITOR" ) ;
26+ #endif
27+ #if UNITY_EDITOR_WIN // #define directive for Editor code on Windows.
28+ defines . Add ( "UNITY_EDITOR_WIN" ) ;
29+ #endif
30+ #if UNITY_EDITOR_OSX // #define directive for Editor code on Mac OS X.
31+ defines . Add ( "UNITY_EDITOR_OSX" ) ;
32+ #endif
33+ #if UNITY_EDITOR_LINUX // #define directive for Editor code on Linux.
34+ defines . Add ( "UNITY_EDITOR_LINUX" ) ;
35+ #endif
36+ #if UNITY_STANDALONE_OSX // #define directive to compile or execute code specifically for Mac OS X (including Universal, PPC and Intel architectures).
37+ defines . Add ( "UNITY_STANDALONE_OSX" ) ;
38+ #endif
39+ #if UNITY_STANDALONE_WIN // #define directive for compiling/executing code specifically for Windows standalone applications.
40+ defines . Add ( "UNITY_STANDALONE_WIN" ) ;
41+ #endif
42+ #if UNITY_STANDALONE_LINUX // #define directive for compiling/executing code specifically for Linux standalone applications.
43+ defines . Add ( "UNITY_STANDALONE_LINUX" ) ;
44+ #endif
45+ #if UNITY_STANDALONE // #define directive for compiling/executing code for any standalone platform (Mac OS X, Windows or Linux).
46+ defines . Add ( "UNITY_STANDALONE" ) ;
47+ #endif
48+ #if UNITY_WII // #define directive for compiling/executing code for the Wii console.
49+ defines . Add ( "UNITY_WII" ) ;
50+ #endif
51+ #if UNITY_IOS // #define directive for compiling/executing code for the iOS platform.
52+ defines . Add ( "UNITY_IOS" ) ;
53+ #endif
54+ #if UNITY_IPHONE // Deprecated. Use UNITY_IOS instead.
55+ defines . Add ( "UNITY_IPHONE" ) ;
56+ #endif
57+ #if UNITY_ANDROID // #define directive for the Android platform.
58+ defines . Add ( "UNITY_ANDROID" ) ;
59+ #endif
60+ #if UNITY_PS4 // #define directive for running PlayStation 4 code.
61+ defines . Add ( "UNITY_PS4" ) ;
62+ #endif
63+ #if UNITY_XBOXONE // #define directive for executing Xbox One code.
64+ defines . Add ( "UNITY_XBOXONE" ) ;
65+ #endif
66+ #if UNITY_LUMIN // #define directive for the Magic Leap OS platform. You can also use PLATFORM_LUMIN.
67+ defines . Add ( "UNITY_LUMIN" ) ;
68+ #endif
69+ #if UNITY_TIZEN // #define directive for the Tizen platform.
70+ defines . Add ( "UNITY_TIZEN" ) ;
71+ #endif
72+ #if UNITY_TVOS // #define directive for the Apple TV platform.
73+ defines . Add ( "UNITY_TVOS" ) ;
74+ #endif
75+ #if UNITY_WSA // #define directive for Universal Windows Platform
76+ defines . Add ( "UNITY_WSA" ) ;
77+ #endif
78+ #if UNITY_WSA_10_0 // #define directive for Universal Windows Platform. Additionally WINDOWS_UWP is defined when compiling C# files against .NET Core.
79+ defines . Add ( "UNITY_WSA_10_0" ) ;
80+ #endif
81+ #if UNITY_WINRT // Same as UNITY_WSA.
82+ defines . Add ( "UNITY_WINRT" ) ;
83+ #endif
84+ #if UNITY_WINRT_10_0 // Equivalent to UNITY_WSA_10_0
85+ defines . Add ( "UNITY_WINRT_10_0" ) ;
86+ #endif
87+ #if UNITY_WEBGL // #define directive for WebGL
88+ defines . Add ( "UNITY_WEBGL" ) ;
89+ #endif
90+ #if UNITY_FACEBOOK // #define directive for the Facebook platform (WebGL or Windows standalone).
91+ defines . Add ( "UNITY_FACEBOOK" ) ;
92+ #endif
93+ #if UNITY_ANALYTICS // #define directive for calling Unity Analytics
94+ defines . Add ( "UNITY_ANALYTICS" ) ;
95+ #endif
96+ #if UNITY_ASSERTIONS // #define directive for assertions control process.
97+ defines . Add ( "UNITY_ASSERTIONS" ) ;
98+ #endif
99+ #if UNITY_64 // #define directive for 64-bit platforms.
100+ defines . Add ( "UNITY_64" ) ;
101+ #endif
102+ #if UNITY_SERVER
103+ defines . Add ( "UNITY_SERVER" ) ;
104+ #endif
105+ return defines ;
106+ }
107+
108+ #if ! JSB_UNITYLESS && UNITY_EDITOR
109+ public static UnityEditor . BuildTargetGroup GetBuildTargetGroup ( )
110+ {
111+ var buildTarget = UnityEditor . EditorUserBuildSettings . activeBuildTarget ;
112+ switch ( buildTarget )
113+ {
114+ case UnityEditor . BuildTarget . Android : return UnityEditor . BuildTargetGroup . Android ;
115+ case UnityEditor . BuildTarget . iOS : return UnityEditor . BuildTargetGroup . iOS ;
116+ case UnityEditor . BuildTarget . WSAPlayer : return UnityEditor . BuildTargetGroup . WSA ;
117+ #if ! UNITY_2019_2_OR_NEWER
118+ case UnityEditor . BuildTarget . StandaloneLinux :
119+ case UnityEditor . BuildTarget . StandaloneLinuxUniversal :
120+ #endif
121+ case UnityEditor . BuildTarget . StandaloneLinux64 :
122+ case UnityEditor . BuildTarget . StandaloneOSX :
123+ case UnityEditor . BuildTarget . StandaloneWindows :
124+ case UnityEditor . BuildTarget . StandaloneWindows64 : return UnityEditor . BuildTargetGroup . Standalone ;
125+ case UnityEditor . BuildTarget . Switch : return UnityEditor . BuildTargetGroup . Switch ;
126+ case UnityEditor . BuildTarget . PS4 : return UnityEditor . BuildTargetGroup . PS4 ;
127+ case UnityEditor . BuildTarget . XboxOne : return UnityEditor . BuildTargetGroup . XboxOne ;
128+ }
129+ throw new NotImplementedException ( ) ;
130+ }
131+ #endif
132+
20133 public InMemoryCompilationBindingCallback ( ScriptRuntime runtime )
21134 {
22135 _runtime = runtime ;
@@ -26,13 +139,13 @@ public InMemoryCompilationBindingCallback(ScriptRuntime runtime)
26139 var compilerOptions = "-unsafe" ;
27140
28141#if ! JSB_UNITYLESS
29- symbolList . AddRange ( Unity . UnityHelper . GetDefinedSymbols ( ) ) ;
142+ symbolList . AddRange ( GetDefinedSymbols ( ) ) ;
30143#endif
31144
32145 defines += string . Join ( ";" , symbolList ) ;
33146
34147#if ! JSB_UNITYLESS && UNITY_EDITOR
35- var customDefinedSymbols = UnityEditor . PlayerSettings . GetScriptingDefineSymbolsForGroup ( Unity . UnityHelper . GetBuildTargetGroup ( ) ) ;
148+ var customDefinedSymbols = UnityEditor . PlayerSettings . GetScriptingDefineSymbolsForGroup ( GetBuildTargetGroup ( ) ) ;
36149 if ( ! string . IsNullOrEmpty ( customDefinedSymbols ) )
37150 {
38151 defines += ";" + customDefinedSymbols ;
0 commit comments