static void Build() { var globalSettings = GetGlobalSettings(); // Use this for real release builds - more compression, but much slower build // var mainBundle = BuildOptions.None; // var assetBundle = BuildAssetBundleOptions.None; var mainBundle = BuildOptions.CompressWithLz4; var assetBundle = BuildAssetBundleOptions.ChunkBasedCompression; int count = UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings; var scenes = new string[] { // only main scene UnityEngine.SceneManagement.SceneUtility.GetScenePathByBuildIndex(0), }; var target = EditorUserBuildSettings.activeBuildTarget; var location = GetBuildDestination(); //Back up initial graphics settings var graphicsSettingsPath = Path.Combine(Path.Combine(Directory.GetParent(Application.dataPath).ToString(), "ProjectSettings"), "GraphicsSettings.asset"); var backup = File.ReadAllText(graphicsSettingsPath); //Change shader inclusion settings for specific target ChangeShaderInclusionSettings(globalSettings.shaderInclusionSettings, GlobalSettings.BundleBuildTarget(target)); string oldText = ""; try { //Build bundles BuildScript.BuildAssetBundles( globalSettings.assetBundleSettings, assetBundle, Path.Combine(Directory.GetParent(location).ToString(), "AssetBundles"), target ); UpdateBuildInfo(out oldText); //Build player BuildPipeline.BuildPlayer(scenes, location, target, mainBundle); } catch (Exception e) { throw e; } finally { if (oldText != "") { ResetBuildInfo(oldText); } //Reset graphics settings to initial status File.WriteAllText(graphicsSettingsPath, backup); } var files = new string[] { "Map.txt" }; var source = Application.dataPath + "/../"; var destination = Directory.GetParent(location) + "/"; foreach (var f in files) { string srcFilePath = source + f; string destFolderPath = destination + f; if (File.Exists(srcFilePath) && Directory.Exists(destFolderPath)) { FileUtil.CopyFileOrDirectory(srcFilePath, destFolderPath); } } }