mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-22 17:56:43 +08:00
[unity] Import: Fixed Skeleton not being updated when atlas page texture count changed. Closes #1562.
This commit is contained in:
parent
60bfdd16f0
commit
2b4bbcb4ee
@ -243,7 +243,7 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static void ImportSpineContent (string[] imported, List<string> texturesWithoutMetaFile,
|
public static void ImportSpineContent (string[] imported, List<string> texturesWithoutMetaFile,
|
||||||
bool reimport = false) {
|
bool reimport = false) {
|
||||||
|
|
||||||
var atlasPaths = new List<string>();
|
var atlasPaths = new List<string>();
|
||||||
@ -291,6 +291,8 @@ namespace Spine.Unity.Editor {
|
|||||||
atlases.Add(atlas);
|
atlases.Add(atlas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddDependentSkeletonIfAtlasChanged(skeletonPaths, atlasPaths);
|
||||||
|
|
||||||
// Import skeletons and match them with atlases.
|
// Import skeletons and match them with atlases.
|
||||||
bool abortSkeletonImport = false;
|
bool abortSkeletonImport = false;
|
||||||
foreach (var skeletonPathEntry in skeletonPaths) {
|
foreach (var skeletonPathEntry in skeletonPaths) {
|
||||||
@ -352,6 +354,21 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void AddDependentSkeletonIfAtlasChanged(List<PathAndProblemInfo> skeletonPaths, List<string> 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) {
|
static void ReloadSkeletonData (string skeletonJSONPath, CompatibilityProblemInfo compatibilityProblemInfo) {
|
||||||
string dir = Path.GetDirectoryName(skeletonJSONPath).Replace('\\', '/');
|
string dir = Path.GetDirectoryName(skeletonJSONPath).Replace('\\', '/');
|
||||||
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonJSONPath);
|
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonJSONPath);
|
||||||
@ -372,7 +389,7 @@ namespace Spine.Unity.Editor {
|
|||||||
return;
|
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();
|
skeletonDataAsset.Clear();
|
||||||
|
|
||||||
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(skeletonDataAsset));
|
string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(skeletonDataAsset));
|
||||||
@ -592,7 +609,7 @@ namespace Spine.Unity.Editor {
|
|||||||
AssetDatabase.CreateAsset(skeletonDataAsset, filePath);
|
AssetDatabase.CreateAsset(skeletonDataAsset, filePath);
|
||||||
}
|
}
|
||||||
EditorUtility.SetDirty(skeletonDataAsset);
|
EditorUtility.SetDirty(skeletonDataAsset);
|
||||||
|
|
||||||
SkeletonDataCompatibility.DisplayCompatibilityProblem(compatibilityProblemInfo.DescriptionString(), spineJson);
|
SkeletonDataCompatibility.DisplayCompatibilityProblem(compatibilityProblemInfo.DescriptionString(), spineJson);
|
||||||
return skeletonDataAsset;
|
return skeletonDataAsset;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user