From 5d61effc686f983fab5fe98d9cbbff8a32eb2fca Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 30 Jul 2020 15:59:47 +0200 Subject: [PATCH] [unity] Fixed automatic asset import in Unity 2020.1 (uses Asset Pipeline V2). Also fixes import when using Asset Pipeline V2 at Unity 2019.X. Closes #1727. --- .../Editor/Utility/AssetUtility.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs index d95dfb0f2..54988fdc1 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs @@ -256,7 +256,6 @@ namespace Spine.Unity.Editor { bool reimport = false) { var atlasPaths = new List(); - var spriteAtlasPaths = new List(); var imagePaths = new List(); var skeletonPaths = new List(); CompatibilityProblemInfo compatibilityProblemInfo = null; @@ -273,9 +272,6 @@ namespace Spine.Unity.Editor { if (str.EndsWith(".atlas.txt", System.StringComparison.Ordinal)) atlasPaths.Add(str); break; - case ".spriteatlas": - spriteAtlasPaths.Add(str); - break; case ".png": case ".jpg": imagePaths.Add(str); @@ -295,13 +291,13 @@ namespace Spine.Unity.Editor { } // Import atlases first. - var atlases = new List(); + var newAtlases = new List(); foreach (string ap in atlasPaths) { if (ap.StartsWith("Packages")) continue; TextAsset atlasText = AssetDatabase.LoadAssetAtPath(ap); AtlasAssetBase atlas = IngestSpineAtlas(atlasText, texturesWithoutMetaFile); - atlases.Add(atlas); + newAtlases.Add(atlas); } AddDependentSkeletonIfAtlasChanged(skeletonPaths, atlasPaths); @@ -328,13 +324,14 @@ namespace Spine.Unity.Editor { #if SPINE_TK2D IngestSpineProject(loadedAsset, null); #else - var localAtlases = FindAtlasesAtPath(dir); + var atlasesForSkeleton = FindAtlasesAtPath(dir); + atlasesForSkeleton.AddRange(newAtlases); var requiredPaths = GetRequiredAtlasRegions(skeletonPath); - var atlasMatch = GetMatchingAtlas(requiredPaths, localAtlases); + var atlasMatch = GetMatchingAtlas(requiredPaths, atlasesForSkeleton); if (atlasMatch != null || requiredPaths.Count == 0) { IngestSpineProject(loadedAsset, atlasMatch); } else { - SkeletonImportDialog(skeletonPath, localAtlases, requiredPaths, ref abortSkeletonImport); + SkeletonImportDialog(skeletonPath, atlasesForSkeleton, requiredPaths, ref abortSkeletonImport); } if (abortSkeletonImport) @@ -580,7 +577,10 @@ namespace Spine.Unity.Editor { } protectFromStackGarbageCollection.Remove(atlasAsset); - return (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase)); + // note: at Asset Pipeline V2 this LoadAssetAtPath of the just created + // asset returns null, regardless of refresh calls. + var loadedAtlas = (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase)); + return loadedAtlas != null ? loadedAtlas : atlasAsset; } public static bool SpriteAtlasSettingsNeedAdjustment (UnityEngine.U2D.SpriteAtlas spriteAtlas) {