From 2b4bbcb4ee166b5ef6d022a5dd1884a93ce77db3 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 5 Dec 2019 12:55:04 +0100 Subject: [PATCH] [unity] Import: Fixed Skeleton not being updated when atlas page texture count changed. Closes #1562. --- .../Editor/Utility/AssetUtility.cs | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 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 a4437df04..e2a12061e 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 @@ -243,7 +243,7 @@ namespace Spine.Unity.Editor { } #endregion - public static void ImportSpineContent (string[] imported, List texturesWithoutMetaFile, + public static void ImportSpineContent (string[] imported, List texturesWithoutMetaFile, bool reimport = false) { var atlasPaths = new List(); @@ -291,6 +291,8 @@ namespace Spine.Unity.Editor { atlases.Add(atlas); } + AddDependentSkeletonIfAtlasChanged(skeletonPaths, atlasPaths); + // Import skeletons and match them with atlases. bool abortSkeletonImport = false; foreach (var skeletonPathEntry in skeletonPaths) { @@ -352,6 +354,21 @@ namespace Spine.Unity.Editor { } } + static void AddDependentSkeletonIfAtlasChanged(List skeletonPaths, List atlasPaths) { + foreach (var atlasPath in atlasPaths) { + string skeletonPathJson = atlasPath.Replace(".atlas.txt", ".json"); + string skeletonPathBinary = atlasPath.Replace(".atlas.txt", ".skel.bytes"); + string usedSkeletonPath = System.IO.File.Exists(skeletonPathJson) ? skeletonPathJson : + System.IO.File.Exists(skeletonPathBinary) ? skeletonPathBinary : null; + if (usedSkeletonPath == null) + continue; + + if (skeletonPaths.FindIndex(p => { return p.Key == usedSkeletonPath; } ) < 0) { + skeletonPaths.Add(new PathAndProblemInfo(usedSkeletonPath, null)); + } + } + } + static void ReloadSkeletonData (string skeletonJSONPath, CompatibilityProblemInfo compatibilityProblemInfo) { string dir = Path.GetDirectoryName(skeletonJSONPath).Replace('\\', '/'); TextAsset textAsset = AssetDatabase.LoadAssetAtPath(skeletonJSONPath); @@ -372,7 +389,7 @@ namespace Spine.Unity.Editor { return; } - Debug.LogFormat("Changes to '{0}' detected. Clearing SkeletonDataAsset: {1}", skeletonJSONPath, localPath); + Debug.LogFormat("Changes to '{0}' or atlas detected. Clearing SkeletonDataAsset: {1}", skeletonJSONPath, localPath); skeletonDataAsset.Clear(); string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(skeletonDataAsset)); @@ -592,7 +609,7 @@ namespace Spine.Unity.Editor { AssetDatabase.CreateAsset(skeletonDataAsset, filePath); } EditorUtility.SetDirty(skeletonDataAsset); - + SkeletonDataCompatibility.DisplayCompatibilityProblem(compatibilityProblemInfo.DescriptionString(), spineJson); return skeletonDataAsset; }