[unity] Fixed Atlas asset assignment upon import which did not prioritize an atlas of the same name as the skeleton. Closes #1818.

This commit is contained in:
Harald Csaszar 2020-12-01 16:20:12 +01:00
parent f365815127
commit eb3d56c9e8
2 changed files with 7 additions and 2 deletions

View File

@ -96,7 +96,8 @@ namespace Spine.Unity.Editor {
public void UpdateSkeletonData () {
preview.Clear();
InitializeEditor();
EditorUtility.SetDirty(targetSkeletonDataAsset);
if (targetSkeletonDataAsset)
EditorUtility.SetDirty(targetSkeletonDataAsset);
}
void InitializeEditor () {

View File

@ -324,9 +324,13 @@ namespace Spine.Unity.Editor {
#if SPINE_TK2D
IngestSpineProject(loadedAsset, null);
#else
string skeletonName = Path.GetFileNameWithoutExtension(skeletonPath);
var atlasesForSkeleton = FindAtlasesAtPath(dir);
atlasesForSkeleton.AddRange(newAtlases);
atlasesForSkeleton = atlasesForSkeleton.Union(newAtlases).ToList();
var requiredPaths = GetRequiredAtlasRegions(skeletonPath);
atlasesForSkeleton.Sort((a, b) => (
string.CompareOrdinal(b.name, skeletonName)
- string.CompareOrdinal(a.name, skeletonName)));
var atlasMatch = GetMatchingAtlas(requiredPaths, atlasesForSkeleton);
if (atlasMatch != null || requiredPaths.Count == 0) {
IngestSpineProject(loadedAsset, atlasMatch);