mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-28 04:31:27 +08:00
[unity] Fixed import issue when suitable atlas found in multiple directories, wrong one could be assigned if named identically. Closes #2033.
This commit is contained in:
parent
6b8c6b31cf
commit
dc2bddd883
@ -206,6 +206,14 @@ namespace Spine.Unity.Editor {
|
|||||||
binary = null;
|
binary = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static AtlasAssetBase GetMatchingAtlas (List<string> requiredPaths, string skeletonName,
|
||||||
|
List<AtlasAssetBase> atlasAssets) {
|
||||||
|
atlasAssets.Sort((a, b) => (
|
||||||
|
string.CompareOrdinal(b.name, skeletonName)
|
||||||
|
- string.CompareOrdinal(a.name, skeletonName)));
|
||||||
|
return GetMatchingAtlas(requiredPaths, atlasAssets);
|
||||||
|
}
|
||||||
|
|
||||||
internal static AtlasAssetBase GetMatchingAtlas (List<string> requiredPaths, List<AtlasAssetBase> atlasAssets) {
|
internal static AtlasAssetBase GetMatchingAtlas (List<string> requiredPaths, List<AtlasAssetBase> atlasAssets) {
|
||||||
AtlasAssetBase atlasAssetMatch = null;
|
AtlasAssetBase atlasAssetMatch = null;
|
||||||
|
|
||||||
@ -353,13 +361,30 @@ namespace Spine.Unity.Editor {
|
|||||||
IngestSpineProject(loadedAsset, null);
|
IngestSpineProject(loadedAsset, null);
|
||||||
#else
|
#else
|
||||||
string skeletonName = Path.GetFileNameWithoutExtension(skeletonPath);
|
string skeletonName = Path.GetFileNameWithoutExtension(skeletonPath);
|
||||||
var atlasesForSkeleton = FindAtlasesAtPath(dir);
|
List<string> requiredPaths = GetRequiredAtlasRegions(skeletonPath);
|
||||||
|
|
||||||
|
List<AtlasAssetBase> atlasesForSkeleton = FindAtlasesAtPath(dir);
|
||||||
atlasesForSkeleton = atlasesForSkeleton.Union(newAtlases).ToList();
|
atlasesForSkeleton = atlasesForSkeleton.Union(newAtlases).ToList();
|
||||||
var requiredPaths = GetRequiredAtlasRegions(skeletonPath);
|
List<AtlasAssetBase> atlasesInSameDir = atlasesForSkeleton.Where(
|
||||||
atlasesForSkeleton.Sort((a, b) => (
|
atlas => AssetDatabase.GetAssetPath(atlas).Contains(dir)).ToList();
|
||||||
string.CompareOrdinal(b.name, skeletonName)
|
|
||||||
- string.CompareOrdinal(a.name, skeletonName)));
|
AtlasAssetBase atlasMatch = GetMatchingAtlas(requiredPaths, skeletonName, atlasesInSameDir);
|
||||||
var atlasMatch = GetMatchingAtlas(requiredPaths, atlasesForSkeleton);
|
if (atlasMatch == null && atlasesInSameDir.Count > 0) {
|
||||||
|
AtlasAssetBase firstAtlas = atlasesInSameDir[0];
|
||||||
|
Debug.LogWarning(string.Format(
|
||||||
|
"'{0}' atlas found in skeleton directory does not contain all required attachments",
|
||||||
|
firstAtlas.name), firstAtlas);
|
||||||
|
|
||||||
|
List<AtlasAssetBase> atlasesInOtherDir = atlasesForSkeleton.Except(atlasesInSameDir).ToList();
|
||||||
|
atlasMatch = GetMatchingAtlas(requiredPaths, skeletonName, atlasesInOtherDir);
|
||||||
|
if (atlasMatch != null) {
|
||||||
|
Debug.Log(string.Format(
|
||||||
|
"Using suitable atlas '{0}' of other imported directory. If this is the " +
|
||||||
|
"wrong atlas asset, please assign the correct one at the SkeletonData asset.",
|
||||||
|
atlasMatch.name), atlasMatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (atlasMatch != null || requiredPaths.Count == 0) {
|
if (atlasMatch != null || requiredPaths.Count == 0) {
|
||||||
IngestSpineProject(loadedAsset, atlasMatch);
|
IngestSpineProject(loadedAsset, atlasMatch);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user