public static BuildPipelineCodes BuildPlayerScripts(ScriptCompilationSettings settings, out ScriptCompilationResult result, bool useCache = true) { var buildTimer = new Stopwatch(); buildTimer.Start(); BuildPipelineCodes exitCode; using (var progressTracker = new BuildProgressTracker(1)) { using (var buildCleanup = new BuildStateCleanup(false, kTempPlayerBuildPath)) { var scriptDependency = new ScriptDependency(useCache, progressTracker); exitCode = scriptDependency.Convert(settings, kTempPlayerBuildPath, out result); if (exitCode < BuildPipelineCodes.Success) { return(exitCode); } } } buildTimer.Stop(); if (exitCode >= BuildPipelineCodes.Success) { BuildLogger.Log("Build Player Scripts successful in: {0:c}", buildTimer.Elapsed); } else if (exitCode == BuildPipelineCodes.Canceled) { BuildLogger.LogWarning("Build Player Scripts canceled in: {0:c}", buildTimer.Elapsed); } else { BuildLogger.LogError("Build Player Scripts failed in: {0:c}", buildTimer.Elapsed); } return(exitCode); }
public static BuildPipelineCodes BuildAssetBundles(BuildInput input, BuildSettings settings, BuildCompression compression, string outputFolder, out BuildResultInfo result, object callbackUserData = null, bool useCache = true) { var buildTimer = new Stopwatch(); buildTimer.Start(); if (ProjectValidator.HasDirtyScenes()) { result = new BuildResultInfo(); buildTimer.Stop(); BuildLogger.LogError("Build Asset Bundles failed in: {0:c}. Error: {1}.", buildTimer.Elapsed, BuildPipelineCodes.UnsavedChanges); return(BuildPipelineCodes.UnsavedChanges); } var exitCode = BuildPipelineCodes.Success; result = new BuildResultInfo(); AssetDatabase.SaveAssets(); // TODO: Until new AssetDatabaseV2 is online, we need to switch platforms EditorUserBuildSettings.SwitchActiveBuildTarget(settings.group, settings.target); var stepCount = BundleDependencyStep.StepCount + BundlePackingStep.StepCount + BundleWritingStep.StepCount; using (var progressTracker = new BuildProgressTracker(stepCount)) { using (var buildCleanup = new BuildStateCleanup(true, kTempBundleBuildPath)) { BuildDependencyInfo buildInfo; exitCode = BundleDependencyStep.Build(input, settings, out buildInfo, useCache, progressTracker); if (exitCode < BuildPipelineCodes.Success) { return(exitCode); } if (PostBuildDependency != null) { exitCode = PostBuildDependency.Invoke(buildInfo, callbackUserData); if (exitCode < BuildPipelineCodes.Success) { return(exitCode); } } BuildWriteInfo writeInfo; exitCode = BundlePackingStep.Build(buildInfo, out writeInfo, useCache, progressTracker); if (exitCode < BuildPipelineCodes.Success) { return(exitCode); } if (PostBuildPacking != null) { exitCode = PostBuildPacking.Invoke(buildInfo, writeInfo, callbackUserData); if (exitCode < BuildPipelineCodes.Success) { return(exitCode); } } exitCode = BundleWritingStep.Build(settings, compression, outputFolder, buildInfo, writeInfo, out result, useCache, progressTracker); if (exitCode < BuildPipelineCodes.Success) { return(exitCode); } if (PostBuildWriting != null) { exitCode = PostBuildWriting.Invoke(buildInfo, writeInfo, result, callbackUserData); if (exitCode < BuildPipelineCodes.Success) { return(exitCode); } } } } buildTimer.Stop(); if (exitCode >= BuildPipelineCodes.Success) { BuildLogger.Log("Build Asset Bundles successful in: {0:c}", buildTimer.Elapsed); } else if (exitCode == BuildPipelineCodes.Canceled) { BuildLogger.LogWarning("Build Asset Bundles canceled in: {0:c}", buildTimer.Elapsed); } else { BuildLogger.LogError("Build Asset Bundles failed in: {0:c}. Error: {1}.", buildTimer.Elapsed, exitCode); } return(exitCode); }