From 491c169cc079094bf9a2dd21bd10a6844500fceb Mon Sep 17 00:00:00 2001 From: Favo Yang Date: Thu, 31 Mar 2022 23:59:29 +0800 Subject: [PATCH] fix: folder ends with '~' should be ignored #72 --- Editor/AddressableImporter.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Editor/AddressableImporter.cs b/Editor/AddressableImporter.cs index 641c5e6..ec6961d 100644 --- a/Editor/AddressableImporter.cs +++ b/Editor/AddressableImporter.cs @@ -57,6 +57,8 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse #endif foreach (var importedAsset in importedAssets) { + if (IsAssetIgnored(importedAsset)) + continue; if (prefabStage == null || prefabAssetPath != importedAsset) // Ignore current editing prefab asset. dirty |= ApplyImportRule(importedAsset, null, settings, importSettings); } @@ -64,6 +66,8 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse for (var i = 0; i < movedAssets.Length; i++) { var movedAsset = movedAssets[i]; + if (IsAssetIgnored(movedAsset)) + continue; var movedFromAssetPath = movedFromAssetPaths[i]; if (prefabStage == null || prefabAssetPath != movedAsset) // Ignore current editing prefab asset. dirty |= ApplyImportRule(movedAsset, movedFromAssetPath, settings, importSettings); @@ -71,6 +75,8 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse foreach (var deletedAsset in deletedAssets) { + if (IsAssetIgnored(deletedAsset)) + continue; if (TryGetMatchedRule(deletedAsset, importSettings, out var matchedRule)) { var guid = AssetDatabase.AssetPathToGUID(deletedAsset); @@ -88,6 +94,11 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse } } + static bool IsAssetIgnored(string assetPath) + { + return assetPath.EndsWith(".meta") || assetPath.EndsWith(".DS_Store") || assetPath.EndsWith("~"); + } + static AddressableAssetGroup CreateAssetGroup(AddressableAssetSettings settings, string groupName) { return settings.CreateGroup(groupName, false, false, false, new List { settings.DefaultGroup.Schemas[0] }, typeof(SchemaType)); @@ -281,7 +292,7 @@ public static void ReimportFolders(IEnumerable assetPaths) foreach (var file in filesToAdd) { // Filter out meta and DS_Store files. - if (!file.EndsWith(".meta") && !file.EndsWith(".DS_Store")) + if (!IsAssetIgnored(file)) { pathsToImport.Add(file.Replace('\\', '/')); }