public static void BuildContentUpdate() { var buildPath = ContentUpdateScript.GetContentStateDataPath(false); var settings = AddressableAssetSettingsDefaultObject.Settings; ContentUpdateScript.BuildContentUpdate(settings, buildPath); }
public static string Build() { RefreshAssetsList(); var path = ContentUpdateScript.GetContentStateDataPath(false); var res = ""; if (File.Exists(path)) { // すでにStateDataがあれば、ContentUpdate(差分)ビルドします var result = ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path); if (result != null) { res = result.Error; } else { // エラーが発生したため、初回ビルドとして処理する AddressableAssetSettings.BuildPlayerContent(); Debug.Log("BuildContentUpdate Error:初回ビルドで処理する"); } } else { // StateDataがなければ、初回ビルドする AddressableAssetSettings.BuildPlayerContent(); } return(res); }
public static void CheckForUpdateContent() { //与上次打包做资源对比 string buildPath = ContentUpdateScript.GetContentStateDataPath(false); var m_Settings = AddressableAssetSettingsDefaultObject.Settings; List <AddressableAssetEntry> entrys = ContentUpdateScript.GatherModifiedEntries(m_Settings, buildPath); if (entrys.Count == 0) { Debug.Log("没有资源变更"); return; } StringBuilder sbuider = new StringBuilder(); sbuider.AppendLine("Need Update Assets:"); foreach (var _ in entrys) { sbuider.AppendLine(_.address); } Debug.Log(sbuider.ToString()); //将被修改过的资源单独分组---可以自定义组名 var groupName = string.Format("UpdateGroup_{0}", DateTime.Now.ToString("yyyyMMddHHmmss")); ContentUpdateScript.CreateContentUpdateGroup(m_Settings, entrys, groupName); }
public static void BuildUpdate() { var path = ContentUpdateScript.GetContentStateDataPath(false); var m_Settings = AddressableAssetSettingsDefaultObject.Settings; AddressablesPlayerBuildResult result = ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path); Debug.Log("BuildFinish path = " + m_Settings.RemoteCatalogBuildPath.GetValue(m_Settings)); }
public static void BuildUpdate() { CreateVersionBuild.CreateVersion(); SetDataBuilder(); string path = ContentUpdateScript.GetContentStateDataPath(false); ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path); }
void OnPrepareUpdate() { var path = ContentUpdateScript.GetContentStateDataPath(true); if (!string.IsNullOrEmpty(path)) { ContentUpdatePreviewWindow.PrepareForContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path); } }
public override void Build(BuildTarget target, Model.NodeData node, IEnumerable <PerformGraph.AssetGroups> incoming, IEnumerable <Model.ConnectionData> connectionsToOutput, PerformGraph.Output Output, Action <Model.NodeData, string, float> progressFunc) { var updatePerformed = false; if (!string.IsNullOrEmpty(m_profileName) && m_profileName != kCurrentProfile) { Settings.activeProfileId = AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileId(m_profileName); //AddressableAssetSettingsDefaultObject.Settings.activeProfileId = AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileId(m_profileName); } if (m_preferUpdate) { if (string.IsNullOrEmpty(m_contentStateFilePath) || !File.Exists(m_contentStateFilePath)) { m_contentStateFilePath = ContentUpdateScript.GetContentStateDataPath(false); } if (!string.IsNullOrEmpty(m_contentStateFilePath) && File.Exists(m_contentStateFilePath)) { ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, m_contentStateFilePath); updatePerformed = true; } } if (!updatePerformed) { var index = Settings.DataBuilders.IndexOf(m_currentDataBuilder); AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilderIndex = index; AddressableAssetSettings.BuildPlayerContent(); } // AddressableBuilder does not add, filter or change structure of group, so just pass given group of assets if (Output != null) { var dst = (connectionsToOutput == null || !connectionsToOutput.Any()) ? null : connectionsToOutput.First(); if (incoming != null) { foreach (var ag in incoming) { Output(dst, ag.assetGroups); } } else { Output(dst, new Dictionary <string, List <AssetReference> >()); } } }
void OnUpdateBuild() { var path = ContentUpdateScript.GetContentStateDataPath(true); if (!string.IsNullOrEmpty(path)) { ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path); } }
private void PostProcessCatalogEnteries(AddressableAssetGroup group, IBundleWriteData writeData, List <ContentCatalogDataEntry> locations, FileRegistry fileRegistry) { if (!group.HasSchema <BundledAssetGroupSchema>() || !File.Exists(ContentUpdateScript.GetContentStateDataPath(false))) { return; } AddressablesContentState contentState = ContentUpdateScript.LoadContentState(ContentUpdateScript.GetContentStateDataPath(false)); foreach (AddressableAssetEntry entry in group.entries) { CachedAssetState cachedAsset = contentState.cachedInfos.FirstOrDefault(i => i.asset.guid.ToString() == entry.guid); if (cachedAsset != null) { if (entry.parentGroup.Guid == cachedAsset.groupGuid) { GUID guid = new GUID(entry.guid); if (!writeData.AssetToFiles.ContainsKey(guid)) { continue; } string file = writeData.AssetToFiles[guid][0]; string fullBundleName = writeData.FileToBundle[file]; ContentCatalogDataEntry catalogBundleEntry = locations.FirstOrDefault((loc) => (loc.Keys[0] as string) == fullBundleName); if (catalogBundleEntry != null) { if (String.IsNullOrEmpty(entry.BundleFileId)) { entry.BundleFileId = catalogBundleEntry.InternalId; } else { if (catalogBundleEntry.InternalId != cachedAsset.bundleFileId) { string unusedBundlePath = fileRegistry.GetFilePathForBundle( Path.GetFileNameWithoutExtension(fullBundleName)); if (File.Exists(unusedBundlePath) && fileRegistry.ReplaceBundleEntry( Path.GetFileNameWithoutExtension(fullBundleName), cachedAsset.bundleFileId)) { File.Delete(unusedBundlePath); catalogBundleEntry.InternalId = entry.BundleFileId; catalogBundleEntry.Data = cachedAsset.data; } } } } } } } }
private static void PerformAddressablesContentUpdate() { string contentStateDataPath = ContentUpdateScript.GetContentStateDataPath(false); if (!File.Exists(contentStateDataPath)) { throw new Exception("Previous Content State Data missing"); } AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings; ContentUpdateScript.BuildContentUpdate(settings, contentStateDataPath); }
public static void CheckForContentUpdate() { BuildLuaAndProto(); var buildPath = ContentUpdateScript.GetContentStateDataPath(false); var settings = AddressableAssetSettingsDefaultObject.Settings; var entrys = ContentUpdateScript.GatherModifiedEntries(settings, buildPath); if (entrys.Count == 0) { return; } var groupName = string.Format("UpdateGroup_{0}", System.DateTime.Now.ToString("yyyyMMdd")); ContentUpdateScript.CreateContentUpdateGroup(settings, entrys, groupName); }
void OnPrepareUpdate() { var path = ContentUpdateScript.GetContentStateDataPath(true); if (string.IsNullOrEmpty(path)) { Debug.LogWarning("No path specified for Content State Data file."); } else if (!File.Exists(path)) { Debug.LogWarningFormat("No Content State Data file exists at path: {0}"); } else { ContentUpdatePreviewWindow.PrepareForContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path); } }
public static void ShellBuild(string profile = "Default") { SetDataBuilder(); var aaSettings = AddressableAssetSettingsDefaultObject.Settings; if (aaSettings != null && aaSettings.BuildRemoteCatalog) { var id = aaSettings.profileSettings.GetProfileId(profile); aaSettings.activeProfileId = id; string path = ContentUpdateScript.GetContentStateDataPath(false); if (File.Exists(path)) { ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, path); } else { AddressableAssetSettings.BuildPlayerContent(); } } }
/// <summary> /// The method that does the actual building after all the groups have been processed. /// </summary> /// <param name="builderInput">The generic builderInput of the</param> /// <param name="aaContext"></param> /// <typeparam name="TResult"></typeparam> /// <returns></returns> protected virtual TResult DoBuild <TResult>(AddressablesDataBuilderInput builderInput, AddressableAssetsBuildContext aaContext) where TResult : IDataBuilderResult { ExtractDataTask extractData = new ExtractDataTask(); List <CachedAssetState> carryOverCachedState = new List <CachedAssetState>(); var tempPath = Path.GetDirectoryName(Application.dataPath) + "/Library/com.unity.addressables/StreamingAssetsCopy/" + PlatformMappingService.GetPlatform() + "/addressables_content_state.bin"; var playerBuildVersion = builderInput.PlayerVersion; if (m_AllBundleInputDefs.Count > 0) { if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, "Unsaved scenes")); } var buildTarget = builderInput.Target; var buildTargetGroup = builderInput.TargetGroup; var buildParams = new AddressableAssetsBundleBuildParameters( aaContext.settings, aaContext.bundleToAssetGroup, buildTarget, buildTargetGroup, aaContext.settings.buildSettings.bundleBuildPath); var builtinShaderBundleName = aaContext.settings.DefaultGroup.Guid + "_unitybuiltinshaders.bundle"; var buildTasks = RuntimeDataBuildTasks(builtinShaderBundleName); buildTasks.Add(extractData); string aaPath = aaContext.settings.AssetPath; IBundleBuildResults results; using (m_Log.ScopedStep(LogLevel.Info, "ContentPipeline.BuildAssetBundles")) { var exitCode = ContentPipeline.BuildAssetBundles(buildParams, new BundleBuildContent(m_AllBundleInputDefs), out results, buildTasks, aaContext, m_Log); if (exitCode < ReturnCode.Success) { return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, "SBP Error" + exitCode)); } } if (aaContext.settings == null && !string.IsNullOrEmpty(aaPath)) { aaContext.settings = AssetDatabase.LoadAssetAtPath <AddressableAssetSettings>(aaPath); } using (var progressTracker = new UnityEditor.Build.Pipeline.Utilities.ProgressTracker()) using (m_Log.ScopedStep(LogLevel.Info, "GenerateLocationListsTask.Run")) { progressTracker.UpdateTask("Generating Addressables Locations"); GenerateLocationListsTask.Run(aaContext, extractData.WriteData); } var groups = aaContext.settings.groups.Where(g => g != null); using (m_Log.ScopedStep(LogLevel.Info, "PostProcessBundles")) using (var progressTracker = new UnityEditor.Build.Pipeline.Utilities.ProgressTracker()) { progressTracker.UpdateTask("Post Processing AssetBundles"); Dictionary <string, ContentCatalogDataEntry> primaryKeyToCatalogEntry = new Dictionary <string, ContentCatalogDataEntry>(); foreach (var loc in aaContext.locations) { if (loc != null && loc.Keys[0] != null && loc.Keys[0] is string && !primaryKeyToCatalogEntry.ContainsKey((string)loc.Keys[0])) { primaryKeyToCatalogEntry[(string)loc.Keys[0]] = loc; } } foreach (var assetGroup in groups) { if (aaContext.assetGroupToBundles.TryGetValue(assetGroup, out List <string> buildBundles)) { List <string> outputBundles = new List <string>(); for (int i = 0; i < buildBundles.Count; ++i) { var b = m_AllBundleInputDefs.FindIndex(inputDef => buildBundles[i].StartsWith(inputDef.assetBundleName)); outputBundles.Add(b >= 0 ? m_OutputAssetBundleNames[b] : buildBundles[i]); } PostProcessBundles(assetGroup, buildBundles, outputBundles, results, extractData.WriteData, aaContext.runtimeData, aaContext.locations, builderInput.Registry, primaryKeyToCatalogEntry); } } } ProcessCatalogEntriesForBuild(aaContext, m_Log, groups, builderInput, extractData.WriteData, carryOverCachedState, m_BundleToInternalId); foreach (var r in results.WriteResults) { m_Linker.AddTypes(r.Value.includedTypes); } } var contentCatalog = new ContentCatalogData(aaContext.locations, ResourceManagerRuntimeData.kCatalogAddress); contentCatalog.ResourceProviderData.AddRange(m_ResourceProviderData); foreach (var t in aaContext.providerTypes) { contentCatalog.ResourceProviderData.Add(ObjectInitializationData.CreateSerializedInitializationData(t)); } contentCatalog.InstanceProviderData = ObjectInitializationData.CreateSerializedInitializationData(instanceProviderType.Value); contentCatalog.SceneProviderData = ObjectInitializationData.CreateSerializedInitializationData(sceneProviderType.Value); //save catalog var jsonText = JsonUtility.ToJson(contentCatalog); CreateCatalogFiles(jsonText, builderInput, aaContext); foreach (var pd in contentCatalog.ResourceProviderData) { m_Linker.AddTypes(pd.ObjectType.Value); m_Linker.AddTypes(pd.GetRuntimeTypes()); } m_Linker.AddTypes(contentCatalog.InstanceProviderData.ObjectType.Value); m_Linker.AddTypes(contentCatalog.InstanceProviderData.GetRuntimeTypes()); m_Linker.AddTypes(contentCatalog.SceneProviderData.ObjectType.Value); m_Linker.AddTypes(contentCatalog.SceneProviderData.GetRuntimeTypes()); foreach (var io in aaContext.settings.InitializationObjects) { var provider = io as IObjectInitializationDataProvider; if (provider != null) { var id = provider.CreateObjectInitializationData(); aaContext.runtimeData.InitializationObjects.Add(id); m_Linker.AddTypes(id.ObjectType.Value); m_Linker.AddTypes(id.GetRuntimeTypes()); } } m_Linker.AddTypes(typeof(Addressables)); m_Linker.Save(Addressables.BuildPath + "/link.xml"); var settingsPath = Addressables.BuildPath + "/" + builderInput.RuntimeSettingsFilename; WriteFile(settingsPath, JsonUtility.ToJson(aaContext.runtimeData), builderInput.Registry); var opResult = AddressableAssetBuildResult.CreateResult <TResult>(settingsPath, aaContext.locations.Count); //save content update data if building for the player var allEntries = new List <AddressableAssetEntry>(); aaContext.settings.GetAllAssets(allEntries, false, g => g != null && g.HasSchema <ContentUpdateGroupSchema>() && g.GetSchema <ContentUpdateGroupSchema>().StaticContent); var remoteCatalogLoadPath = aaContext.settings.BuildRemoteCatalog ? aaContext.settings.RemoteCatalogLoadPath.GetValue(aaContext.settings) : string.Empty; if (extractData.BuildCache != null && ContentUpdateScript.SaveContentState(aaContext.locations, tempPath, allEntries, extractData.DependencyData, playerBuildVersion, remoteCatalogLoadPath, carryOverCachedState)) { try { var contentStatePath = ContentUpdateScript.GetContentStateDataPath(false); File.Copy(tempPath, contentStatePath, true); builderInput.Registry.AddFile(contentStatePath); } catch (Exception e) { Debug.LogException(e); } } return(opResult); }
/// <summary> /// The method that does the actual building after all the groups have been processed. /// </summary> /// <param name="builderInput">The generic builderInput of the</param> /// <param name="aaContext"></param> /// <typeparam name="TResult"></typeparam> /// <returns></returns> protected virtual TResult DoBuild <TResult>(AddressablesDataBuilderInput builderInput, AddressableAssetsBuildContext aaContext) where TResult : IDataBuilderResult { ExtractDataTask extractData = new ExtractDataTask(); var tempPath = Path.GetDirectoryName(Application.dataPath) + "/Library/com.unity.addressables/StreamingAssetsCopy/" + PlatformMappingService.GetPlatform() + "/addressables_content_state.bin"; var playerBuildVersion = builderInput.PlayerVersion; if (m_AllBundleInputDefs.Count > 0) { if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, "Unsaved scenes")); } var buildTarget = builderInput.Target; var buildTargetGroup = builderInput.TargetGroup; var buildParams = new AddressableAssetsBundleBuildParameters( aaContext.settings, aaContext.bundleToAssetGroup, buildTarget, buildTargetGroup, aaContext.settings.buildSettings.bundleBuildPath); var builtinShaderBundleName = aaContext.settings.DefaultGroup.Name.ToLower().Replace(" ", "").Replace('\\', '/').Replace("//", "/") + "_unitybuiltinshaders.bundle"; var buildTasks = RuntimeDataBuildTasks(builtinShaderBundleName); buildTasks.Add(extractData); string aaPath = aaContext.settings.AssetPath; IBundleBuildResults results; var exitCode = ContentPipeline.BuildAssetBundles(buildParams, new BundleBuildContent(m_AllBundleInputDefs), out results, buildTasks, aaContext); if (exitCode < ReturnCode.Success) { return(AddressableAssetBuildResult.CreateResult <TResult>(null, 0, "SBP Error" + exitCode)); } if (aaContext.settings == null && !string.IsNullOrEmpty(aaPath)) { aaContext.settings = AssetDatabase.LoadAssetAtPath <AddressableAssetSettings>(aaPath); } GenerateLocationListsTask.Run(aaContext, extractData.WriteData); foreach (var assetGroup in aaContext.settings.groups) { List <string> bundles; if (aaContext.assetGroupToBundles.TryGetValue(assetGroup, out bundles)) { PostProcessBundles(assetGroup, bundles, results, extractData.WriteData, aaContext.runtimeData, aaContext.locations, builderInput.Registry); PostProcessCatalogEnteries(assetGroup, extractData.WriteData, aaContext.locations, builderInput.Registry); } } foreach (var r in results.WriteResults) { m_Linker.AddTypes(r.Value.includedTypes); } } //save catalog var contentCatalog = new ContentCatalogData(aaContext.locations); contentCatalog.ResourceProviderData.AddRange(m_ResourceProviderData); foreach (var t in aaContext.providerTypes) { contentCatalog.ResourceProviderData.Add(ObjectInitializationData.CreateSerializedInitializationData(t)); } contentCatalog.InstanceProviderData = ObjectInitializationData.CreateSerializedInitializationData(instanceProviderType.Value); contentCatalog.SceneProviderData = ObjectInitializationData.CreateSerializedInitializationData(sceneProviderType.Value); CreateCatalog(aaContext.settings, contentCatalog, aaContext.runtimeData.CatalogLocations, playerBuildVersion, builderInput.RuntimeCatalogFilename, builderInput.Registry); foreach (var pd in contentCatalog.ResourceProviderData) { m_Linker.AddTypes(pd.ObjectType.Value); m_Linker.AddTypes(pd.GetRuntimeTypes()); } m_Linker.AddTypes(contentCatalog.InstanceProviderData.ObjectType.Value); m_Linker.AddTypes(contentCatalog.InstanceProviderData.GetRuntimeTypes()); m_Linker.AddTypes(contentCatalog.SceneProviderData.ObjectType.Value); m_Linker.AddTypes(contentCatalog.SceneProviderData.GetRuntimeTypes()); foreach (var io in aaContext.settings.InitializationObjects) { var provider = io as IObjectInitializationDataProvider; if (provider != null) { var id = provider.CreateObjectInitializationData(); aaContext.runtimeData.InitializationObjects.Add(id); m_Linker.AddTypes(id.ObjectType.Value); m_Linker.AddTypes(id.GetRuntimeTypes()); } } m_Linker.AddTypes(typeof(Addressables)); m_Linker.Save(Addressables.BuildPath + "/link.xml"); var settingsPath = Addressables.BuildPath + "/" + builderInput.RuntimeSettingsFilename; WriteFile(settingsPath, JsonUtility.ToJson(aaContext.runtimeData), builderInput.Registry); var opResult = AddressableAssetBuildResult.CreateResult <TResult>(settingsPath, aaContext.locations.Count); //save content update data if building for the player var allEntries = new List <AddressableAssetEntry>(); aaContext.settings.GetAllAssets(allEntries, false, g => g.HasSchema <ContentUpdateGroupSchema>() && g.GetSchema <ContentUpdateGroupSchema>().StaticContent); var remoteCatalogLoadPath = aaContext.settings.BuildRemoteCatalog ? aaContext.settings.RemoteCatalogLoadPath.GetValue(aaContext.settings) : string.Empty; if (extractData.BuildCache != null && ContentUpdateScript.SaveContentState(aaContext.locations, tempPath, allEntries, extractData.DependencyData, playerBuildVersion, remoteCatalogLoadPath)) { try { File.Copy(tempPath, ContentUpdateScript.GetContentStateDataPath(false), true); } catch (Exception e) { Debug.LogException(e); } } return(opResult); }
public static void BuildAssets() { ContentUpdateScript.BuildContentUpdate(AddressableAssetSettingsDefaultObject.Settings, ContentUpdateScript.GetContentStateDataPath(false)); LaunchGameOnAndroid(); }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { EditorGUILayout.HelpBox("Build Addressable Assets: Build Addressable Assets.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(4f); EditorGUILayout.HelpBox("Build Addressable Assets does not respect Platform selection in Graph Editor." + "Instead, Addressable Profile will be used for platform targeting.", MessageType.Info); if (!AddressableAssetSettingsDefaultObject.SettingsExists) { return; } var profileNames = Settings.profileSettings.GetAllProfileNames(); profileNames.Insert(0, kCurrentProfile); var profileIndex = string.IsNullOrEmpty(m_profileName) ? 0 : profileNames.IndexOf(m_profileName); var newProfileIndex = EditorGUILayout.Popup("Profile", profileIndex, profileNames.ToArray()); if (newProfileIndex != profileIndex) { using (new RecordUndoScope("Change Profile", node, true)) { m_profileName = profileNames[newProfileIndex]; onValueChanged(); } } if (m_currentDataBuilder == null && !string.IsNullOrEmpty(m_builderGuid)) { m_currentDataBuilder = Settings.DataBuilders.FirstOrDefault(obj => AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)) == m_builderGuid); } var dataBuilders = Settings.DataBuilders.Where(builder => (builder as IDataBuilder).CanBuildData <AddressablesPlayerBuildResult>()).ToList(); var builderIndex = m_currentDataBuilder == null ? -1 : dataBuilders.IndexOf(m_currentDataBuilder); var builderNames = dataBuilders .Select(builder => ((IDataBuilder)builder).Name).ToArray(); var newIndex = EditorGUILayout.Popup("Builder Script", builderIndex, builderNames); if (newIndex != builderIndex) { using (new RecordUndoScope("Change Builder", node, true)) { m_currentDataBuilder = dataBuilders[newIndex]; m_builderGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_currentDataBuilder)); onValueChanged(); } } var newPreferUpdate = EditorGUILayout.ToggleLeft("Update", m_preferUpdate); if (newPreferUpdate != m_preferUpdate) { using (new RecordUndoScope("Update Toggle", node, true)) { m_preferUpdate = newPreferUpdate; onValueChanged(); } } using (new EditorGUI.DisabledScope(!m_preferUpdate)) { GUILayout.Label("Content State File", "BoldLabel"); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.SelectableLabel(m_contentStateFilePath, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); if (GUILayout.Button("Select", GUILayout.Width(50f))) { var newStateData = ContentUpdateScript.GetContentStateDataPath(true); if (newStateData != null && newStateData != m_contentStateFilePath) { using (new RecordUndoScope("Content State Data Path", node, true)) { m_contentStateFilePath = newStateData; onValueChanged(); } } } } } GUILayout.Space(10f); if (GUILayout.Button("Clean Build Cache", GUILayout.Width(250f))) { if (EditorUtility.DisplayDialog("Clean Build Cache", "Do you really want to clean build cache?", "OK", "Cancel")) { AddressableAssetSettings.CleanPlayerContent(null); BuildCache.PurgeCache(false); } } }
private void PostProcessCatalogEnteries(AddressableAssetGroup group, IBundleWriteData writeData, List <ContentCatalogDataEntry> locations, FileRegistry fileRegistry) { if (!group.HasSchema <BundledAssetGroupSchema>() || !File.Exists(ContentUpdateScript.GetContentStateDataPath(false))) { return; } AddressablesContentState contentState = ContentUpdateScript.LoadContentState(ContentUpdateScript.GetContentStateDataPath(false)); foreach (AddressableAssetEntry entry in group.entries) { CachedAssetState cachedAsset = contentState.cachedInfos.FirstOrDefault(i => i.asset.guid.ToString() == entry.guid); if (cachedAsset != null) { GUID guid = new GUID(entry.guid); if (!writeData.AssetToFiles.ContainsKey(guid)) { continue; } string file = writeData.AssetToFiles[guid][0]; string fullBundleName = writeData.FileToBundle[file]; string convertedLocation = m_BundleToInternalId[fullBundleName]; ContentCatalogDataEntry catalogBundleEntry = locations.FirstOrDefault((loc) => loc.InternalId == (convertedLocation)); if (catalogBundleEntry != null) { if (entry.parentGroup.Guid == cachedAsset.groupGuid) { //Asset hash hasn't changed if (AssetDatabase.GetAssetDependencyHash(entry.AssetPath) == cachedAsset.asset.hash) { if (catalogBundleEntry.InternalId != cachedAsset.bundleFileId) { string builtBundlePath = m_BundleToInternalId[fullBundleName].Replace( group.GetSchema <BundledAssetGroupSchema>().LoadPath.GetValue(group.Settings), group.GetSchema <BundledAssetGroupSchema>().BuildPath.GetValue(group.Settings)); string cachedBundlePath = cachedAsset.bundleFileId?.Replace( group.GetSchema <BundledAssetGroupSchema>().LoadPath.GetValue(group.Settings), group.GetSchema <BundledAssetGroupSchema>().BuildPath.GetValue(group.Settings)); //Need to check and make sure our cached version exists if (!string.IsNullOrEmpty(cachedBundlePath) && File.Exists(cachedBundlePath)) { //Try and replace the new bundle entry with the cached one and delete the new bundle if (File.Exists(builtBundlePath) && fileRegistry.ReplaceBundleEntry( Path.GetFileNameWithoutExtension(convertedLocation), cachedAsset.bundleFileId)) { File.Delete(builtBundlePath); catalogBundleEntry.InternalId = cachedAsset.bundleFileId; catalogBundleEntry.Data = cachedAsset.data; entry.BundleFileId = cachedAsset.bundleFileId; } } } } entry.BundleFileId = catalogBundleEntry.InternalId; cachedAsset.bundleFileId = catalogBundleEntry.InternalId; } } } } }