public static void WriteExpectedSharedBundles(AssetbundleBuildSettings settings) { var bundleList = GetAssetBundlesList(settings); var treeResult = AssetDependencyTree.ProcessDependencyTree(bundleList); WriteSharedBundleLog($"{Application.dataPath}/../", treeResult); if (!Application.isBatchMode) { EditorUtility.DisplayDialog("Succeeded!", $"Check {LogExpectedSharedBundleFileName} in your project root directory!", "Confirm"); } }
public static void WriteExpectedSharedBundles(AssetbundleBuildSettings settings) { if (!Application.isBatchMode) { //have to ask save current scene var saved = UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); if (!saved) { EditorUtility.DisplayDialog("Failed!", $"User Canceled", "Confirm"); return; } } var tempPrevSceneKey = "WriteExpectedSharedBundlesPrevScene"; var prevScene = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene(); EditorPrefs.SetString(tempPrevSceneKey, prevScene.path); var bundleList = GetAssetBundlesList(settings); var treeResult = AssetDependencyTree.ProcessDependencyTree(bundleList); WriteSharedBundleLog($"{Application.dataPath}/../", treeResult); if (!Application.isBatchMode) { EditorUtility.DisplayDialog("Succeeded!", $"Check {LogExpectedSharedBundleFileName} in your project root directory!", "Confirm"); } //domain reloaded, we need to restore previous scene path var prevScenePath = EditorPrefs.GetString(tempPrevSceneKey, string.Empty); //back to previous scene as all processed scene's prefabs are unpacked. if (string.IsNullOrEmpty(prevScenePath)) { UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects); } else { UnityEditor.SceneManagement.EditorSceneManager.OpenScene(prevScenePath); } }
public static void WriteExpectedSharedBundles(AssetbundleBuildSettings settings) { if (!Application.isBatchMode) { //have to ask save current scene var saved = UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); if (!saved) { EditorUtility.DisplayDialog("Failed!", $"User Canceled", "Confirm"); return; } } var bundleList = GetAssetBundlesList(settings); var treeResult = AssetDependencyTree.ProcessDependencyTree(bundleList); WriteSharedBundleLog($"{Application.dataPath}/../", treeResult); if (!Application.isBatchMode) { EditorUtility.DisplayDialog("Succeeded!", $"Check {LogExpectedSharedBundleFileName} in your project root directory!", "Confirm"); } }
public static void BuildAssetBundles(AssetbundleBuildSettings settings, BuildType buildType) { if (!Application.isBatchMode) { //have to ask save current scene var saved = UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); if (!saved) { EditorUtility.DisplayDialog("Build Failed!", $"User Canceled", "Confirm"); return; } } var bundleList = GetAssetBundlesList(settings); var buildTarget = EditorUserBuildSettings.activeBuildTarget; var groupTarget = BuildPipeline.GetBuildTargetGroup(buildTarget); var outputPath = Utility.CombinePath(buildType == BuildType.Local ? settings.LocalOutputPath : settings.RemoteOutputPath, buildTarget.ToString()); //generate sharedBundle if needed, and pre generate dependency var treeResult = AssetDependencyTree.ProcessDependencyTree(bundleList); if (settings.AutoCreateSharedBundles) { bundleList.AddRange(treeResult.SharedBundles); } var buildParams = new CustomBuildParameters(settings, buildTarget, groupTarget, outputPath, treeResult.BundleDependencies, buildType); buildParams.UseCache = !settings.ForceRebuild; if (buildParams.UseCache && settings.UseCacheServer) { buildParams.CacheServerHost = settings.CacheServerHost; buildParams.CacheServerPort = settings.CacheServerPort; } ContentPipeline.BuildCallbacks.PostPackingCallback += PostPackingForSelectiveBuild; var returnCode = ContentPipeline.BuildAssetBundles(buildParams, new BundleBuildContent(bundleList.ToArray()), out var results); ContentPipeline.BuildCallbacks.PostPackingCallback -= PostPackingForSelectiveBuild; if (returnCode == ReturnCode.Success) { //only remote bundle build generates link.xml switch (buildType) { case BuildType.Local: WriteManifestFile(outputPath, results, buildTarget, settings.RemoteURL); WriteLogFile(outputPath, results); if (!Application.isBatchMode) { EditorUtility.DisplayDialog("Build Succeeded!", "Local bundle build succeeded!", "Confirm"); } break; case BuildType.Remote: WriteManifestFile(outputPath, results, buildTarget, settings.RemoteURL); WriteLogFile(outputPath, results); var linkPath = TypeLinkerGenerator.Generate(settings, results); if (!Application.isBatchMode) { EditorUtility.DisplayDialog("Build Succeeded!", $"Remote bundle build succeeded, \n {linkPath} updated!", "Confirm"); } if (settings.AutoUploadS3) { LocusAssetbundleUploaderExtension.UploadToS3Bucket(settings); } break; } } else { EditorUtility.DisplayDialog("Build Failed!", $"Bundle build failed, \n Code : {returnCode}", "Confirm"); Debug.LogError(returnCode); } }