mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-19 08:16:41 +08:00
[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.
This commit is contained in:
parent
1c2d4fa2e0
commit
5d61effc68
@ -256,7 +256,6 @@ namespace Spine.Unity.Editor {
|
|||||||
bool reimport = false) {
|
bool reimport = false) {
|
||||||
|
|
||||||
var atlasPaths = new List<string>();
|
var atlasPaths = new List<string>();
|
||||||
var spriteAtlasPaths = new List<string>();
|
|
||||||
var imagePaths = new List<string>();
|
var imagePaths = new List<string>();
|
||||||
var skeletonPaths = new List<PathAndProblemInfo>();
|
var skeletonPaths = new List<PathAndProblemInfo>();
|
||||||
CompatibilityProblemInfo compatibilityProblemInfo = null;
|
CompatibilityProblemInfo compatibilityProblemInfo = null;
|
||||||
@ -273,9 +272,6 @@ namespace Spine.Unity.Editor {
|
|||||||
if (str.EndsWith(".atlas.txt", System.StringComparison.Ordinal))
|
if (str.EndsWith(".atlas.txt", System.StringComparison.Ordinal))
|
||||||
atlasPaths.Add(str);
|
atlasPaths.Add(str);
|
||||||
break;
|
break;
|
||||||
case ".spriteatlas":
|
|
||||||
spriteAtlasPaths.Add(str);
|
|
||||||
break;
|
|
||||||
case ".png":
|
case ".png":
|
||||||
case ".jpg":
|
case ".jpg":
|
||||||
imagePaths.Add(str);
|
imagePaths.Add(str);
|
||||||
@ -295,13 +291,13 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Import atlases first.
|
// Import atlases first.
|
||||||
var atlases = new List<AtlasAssetBase>();
|
var newAtlases = new List<AtlasAssetBase>();
|
||||||
foreach (string ap in atlasPaths) {
|
foreach (string ap in atlasPaths) {
|
||||||
if (ap.StartsWith("Packages"))
|
if (ap.StartsWith("Packages"))
|
||||||
continue;
|
continue;
|
||||||
TextAsset atlasText = AssetDatabase.LoadAssetAtPath<TextAsset>(ap);
|
TextAsset atlasText = AssetDatabase.LoadAssetAtPath<TextAsset>(ap);
|
||||||
AtlasAssetBase atlas = IngestSpineAtlas(atlasText, texturesWithoutMetaFile);
|
AtlasAssetBase atlas = IngestSpineAtlas(atlasText, texturesWithoutMetaFile);
|
||||||
atlases.Add(atlas);
|
newAtlases.Add(atlas);
|
||||||
}
|
}
|
||||||
AddDependentSkeletonIfAtlasChanged(skeletonPaths, atlasPaths);
|
AddDependentSkeletonIfAtlasChanged(skeletonPaths, atlasPaths);
|
||||||
|
|
||||||
@ -328,13 +324,14 @@ namespace Spine.Unity.Editor {
|
|||||||
#if SPINE_TK2D
|
#if SPINE_TK2D
|
||||||
IngestSpineProject(loadedAsset, null);
|
IngestSpineProject(loadedAsset, null);
|
||||||
#else
|
#else
|
||||||
var localAtlases = FindAtlasesAtPath(dir);
|
var atlasesForSkeleton = FindAtlasesAtPath(dir);
|
||||||
|
atlasesForSkeleton.AddRange(newAtlases);
|
||||||
var requiredPaths = GetRequiredAtlasRegions(skeletonPath);
|
var requiredPaths = GetRequiredAtlasRegions(skeletonPath);
|
||||||
var atlasMatch = GetMatchingAtlas(requiredPaths, localAtlases);
|
var atlasMatch = GetMatchingAtlas(requiredPaths, atlasesForSkeleton);
|
||||||
if (atlasMatch != null || requiredPaths.Count == 0) {
|
if (atlasMatch != null || requiredPaths.Count == 0) {
|
||||||
IngestSpineProject(loadedAsset, atlasMatch);
|
IngestSpineProject(loadedAsset, atlasMatch);
|
||||||
} else {
|
} else {
|
||||||
SkeletonImportDialog(skeletonPath, localAtlases, requiredPaths, ref abortSkeletonImport);
|
SkeletonImportDialog(skeletonPath, atlasesForSkeleton, requiredPaths, ref abortSkeletonImport);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abortSkeletonImport)
|
if (abortSkeletonImport)
|
||||||
@ -580,7 +577,10 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protectFromStackGarbageCollection.Remove(atlasAsset);
|
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) {
|
public static bool SpriteAtlasSettingsNeedAdjustment (UnityEngine.U2D.SpriteAtlas spriteAtlas) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user