public static void BuildPlatform(BuildTarget platform, string[] scenes) { var platformPath = DirUtils.PlatformBuildPath(platform); if (platformPath == null) { Debug.LogWarningFormat(string.Format("Do not know info for {0}", platform)); return; } var previousGroup = EditorUserBuildSettings.selectedBuildTargetGroup; var previousTarget = EditorUserBuildSettings.activeBuildTarget; if (!Directory.Exists(Constants.BuildPath)) { Directory.CreateDirectory(Constants.BuildPath); } try { // DirUtils.RmStreamingBundle(); // CreateAssetBundles.EnsureBuilt(platform, setStreamingAssets:true); BuildPipeline.BuildPlayer(new BuildPlayerOptions { target = platform, scenes = scenes, locationPathName = platformPath, options = BuildOptions.None }); } finally { EditorUserBuildSettings.SwitchActiveBuildTarget(previousGroup, previousTarget); } }