From 3e3dbe59d0677d88620fbfae6c10ed3a81bd24f5 Mon Sep 17 00:00:00 2001 From: ChaosVan Date: Fri, 25 Aug 2023 16:33:26 +0800 Subject: [PATCH 1/2] some opt 1.fix check config pass mistake 2.ignore empty label 3.ignore folder name end with '~' --- Editor/AddressableImporter.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Editor/AddressableImporter.cs b/Editor/AddressableImporter.cs index e8f201c..93ad16a 100644 --- a/Editor/AddressableImporter.cs +++ b/Editor/AddressableImporter.cs @@ -37,8 +37,8 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse { // Skip if all imported and deleted assets are addressables configurations. var isConfigurationPass = - (importedAssets.Length > 0 && importedAssets.All(x => x.StartsWith("Assets/AddressableAssetsData"))) && - (deletedAssets.Length > 0 && deletedAssets.All(x => x.StartsWith("Assets/AddressableAssetsData"))); + (importedAssets.Length == 0 || importedAssets.All(x => x.StartsWith("Assets/AddressableAssetsData"))) && + (deletedAssets.Length == 0 || deletedAssets.All(x => x.StartsWith("Assets/AddressableAssetsData"))); if (isConfigurationPass) { return; @@ -277,8 +277,11 @@ static AddressableAssetEntry CreateOrUpdateAddressableAssetEntry( foreach (var dynamicLabel in rule.dynamicLabels) { var label = rule.ParseReplacement(assetPath, dynamicLabel); - settings.AddLabel(label); - entry.labels.Add(label); + if (!string.IsNullOrEmpty(label)) + { + settings.AddLabel(label); + entry.labels.Add(label); + } } } } @@ -363,10 +366,14 @@ public static void ReimportFolders(IEnumerable assetPaths, bool showConf var filesToAdd = Directory.GetFiles(assetPath, "*", SearchOption.AllDirectories); foreach (var file in filesToAdd) { + var filePath = file.Replace('\\', '/'); + if (filePath.Contains("~/")) + continue; + // Filter out meta and DS_Store files. - if (!IsAssetIgnored(file)) + if (!IsAssetIgnored(filePath)) { - pathsToImport.Add(file.Replace('\\', '/')); + pathsToImport.Add(filePath); } } } From 52f96173b6f4c710977384756aac3bf5d5a3de0f Mon Sep 17 00:00:00 2001 From: ChaosVan Date: Mon, 28 Aug 2023 10:59:50 +0800 Subject: [PATCH 2/2] some optimize 1.fix isConfigurationPass mistake 2.opt folders and files collection process --- Editor/AddressableImporter.cs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Editor/AddressableImporter.cs b/Editor/AddressableImporter.cs index 93ad16a..66a012c 100644 --- a/Editor/AddressableImporter.cs +++ b/Editor/AddressableImporter.cs @@ -38,7 +38,9 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse // Skip if all imported and deleted assets are addressables configurations. var isConfigurationPass = (importedAssets.Length == 0 || importedAssets.All(x => x.StartsWith("Assets/AddressableAssetsData"))) && - (deletedAssets.Length == 0 || deletedAssets.All(x => x.StartsWith("Assets/AddressableAssetsData"))); + (deletedAssets.Length == 0 || deletedAssets.All(x => x.StartsWith("Assets/AddressableAssetsData"))) && + movedAssets.Length == 0 && movedFromAssetPaths.Length == 0; + if (isConfigurationPass) { return; @@ -93,7 +95,7 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse if (importSettingsList.ShowImportProgressBar && EditorUtility.DisplayCancelableProgressBar( "Processing addressable import settings", $"[{i}/{importedAssets.Length}] {importedAsset}", - (float) i / importedAssets.Length)) + (float)i / importedAssets.Length)) break; foreach (var importSettings in hasRuleSettingsList) @@ -229,7 +231,8 @@ static AddressableAssetEntry CreateOrUpdateAddressableAssetEntry( // Set group settings from template if necessary if (rule.groupTemplate != null && (newGroup || rule.groupTemplateApplicationMode == - GroupTemplateApplicationMode.AlwaysOverwriteGroupSettings)) { + GroupTemplateApplicationMode.AlwaysOverwriteGroupSettings)) + { // Due to ApplyToAddressableAssetGroup only applies schema values for the group to the schema // values found in the source template, all schema objects of the source template should be // manually added to the target group before run the ApplyToAddressableAssetGroup function. @@ -360,20 +363,17 @@ public static void ReimportFolders(IEnumerable assetPaths, bool showConf if (!dir.StartsWith(".") && !dir.EndsWith("~")) { pathsToImport.Add(dir.Replace('\\', '/')); - } - } - // Add files. - var filesToAdd = Directory.GetFiles(assetPath, "*", SearchOption.AllDirectories); - foreach (var file in filesToAdd) - { - var filePath = file.Replace('\\', '/'); - if (filePath.Contains("~/")) - continue; - // Filter out meta and DS_Store files. - if (!IsAssetIgnored(filePath)) - { - pathsToImport.Add(filePath); + // Add files. + var filesToAdd = Directory.GetFiles(dir, "*", SearchOption.TopDirectoryOnly); + foreach (var file in filesToAdd) + { + // Filter out meta and DS_Store files. + if (!IsAssetIgnored(file)) + { + pathsToImport.Add(file.Replace('\\', '/')); + } + } } } }