(Unity) 使用 BuildPipeline 构建时启用 App Bundle (Google Play) 选项?

(Unity) Enabling App Bundle (Google Play) option when building with the BuildPipeline?

有人知道在使用 Unity BuildPipeline 构建时如何启用 App Bundle (Google Play) 选项吗?试图让它与我们的 CI 服务器一起工作,这是当前用于创建 APK 的代码:

BuildPlayerOptions prodBuildPlayerOptions = new BuildPlayerOptions();
 prodBuildPlayerOptions.scenes = scenes;
 prodBuildPlayerOptions.locationPathName = $"PSS.Prod.{baseBuildFileName}.apk";
 prodBuildPlayerOptions.target = BuildTarget.Android;
 prodBuildPlayerOptions.options = BuildOptions.None;
 BuildPipeline.BuildPlayer(prodBuildPlayerOptions);

如有任何帮助,我们将不胜感激! 干杯,托马斯

我在旧版本 Unity(2017.4.1f1) 中使用此代码,我认为您可以在 'EditorUserBuildSetting' 中找到 AppBundle 选项,如下所示:

EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;

根据document,只需做:

EditorUserBuildSettings.buildAppBundle = true;

如果Unity版本低于2018,还需要设置:

EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;