@@ -70,8 +70,17 @@ public static void Build()
7070 break ;
7171 }
7272
73+ // Determine subtarget
74+ int buildSubtarget = 0 ;
75+ #if UNITY_2021_2_OR_NEWER
76+ if ( ! options . TryGetValue ( "standaloneBuildSubtarget" , out var subtargetValue ) || ! Enum . TryParse ( subtargetValue , out StandaloneBuildSubtarget buildSubtargetValue ) ) {
77+ buildSubtargetValue = default ;
78+ }
79+ buildSubtarget = ( int ) buildSubtargetValue ;
80+ #endif
81+
7382 // Custom build
74- Build ( buildTarget , options [ "customBuildPath" ] ) ;
83+ Build ( buildTarget , buildSubtarget , options [ "customBuildPath" ] ) ;
7584 }
7685
7786 private static Dictionary < string , string > GetValidatedOptions ( )
@@ -150,15 +159,8 @@ private static void ParseCommandLineArguments(out Dictionary<string, string> pro
150159 }
151160 }
152161
153- private static void Build ( BuildTarget buildTarget , string filePath )
162+ private static void Build ( BuildTarget buildTarget , int buildSubtarget , string filePath )
154163 {
155- #if UNITY_2021_2_OR_NEWER
156- // Determine subtarget
157- StandaloneBuildSubtarget buildSubtarget ;
158- if ( ! options . TryGetValue ( "standaloneBuildSubtarget" , out var subtargetValue ) || ! Enum . TryParse ( subtargetValue , out buildSubtarget ) ) {
159- buildSubtarget = default ;
160- }
161- #endif
162164 string [ ] scenes = EditorBuildSettings . scenes . Where ( scene => scene . enabled ) . Select ( s => s . path ) . ToArray ( ) ;
163165 var buildPlayerOptions = new BuildPlayerOptions
164166 {
@@ -168,7 +170,7 @@ private static void Build(BuildTarget buildTarget, string filePath)
168170 locationPathName = filePath ,
169171// options = UnityEditor.BuildOptions.Development
170172#if UNITY_2021_2_OR_NEWER
171- subtarget = ( int ) buildSubtarget
173+ subtarget = buildSubtarget
172174#endif
173175 } ;
174176
0 commit comments