|
@@ -65,7 +65,7 @@ namespace Spine.Unity.Editor {
|
|
|
public static readonly List<ScriptableObject> protectFromStackGarbageCollection = new List<ScriptableObject>();
|
|
|
public static HashSet<string> assetsImportedInWrongState = new HashSet<string>();
|
|
|
|
|
|
- public static void HandleOnPostprocessAllAssets (string[] imported) {
|
|
|
+ public static void HandleOnPostprocessAllAssets (string[] imported, List<string> texturesWithoutMetaFile) {
|
|
|
// In case user used "Assets -> Reimport All", during the import process,
|
|
|
// asset database is not initialized until some point. During that period,
|
|
|
// all attempts to load any assets using API (i.e. AssetDatabase.LoadAssetAtPath)
|
|
@@ -87,7 +87,7 @@ namespace Spine.Unity.Editor {
|
|
|
if (AssetDatabaseAvailabilityDetector.IsAssetDatabaseAvailable()) {
|
|
|
string[] combinedAssets = AssetUtility.assetsImportedInWrongState.ToArray();
|
|
|
AssetUtility.assetsImportedInWrongState.Clear();
|
|
|
- AssetUtility.ImportSpineContent(combinedAssets);
|
|
|
+ AssetUtility.ImportSpineContent(combinedAssets, texturesWithoutMetaFile);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -243,7 +243,9 @@ namespace Spine.Unity.Editor {
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- public static void ImportSpineContent (string[] imported, bool reimport = false) {
|
|
|
+ public static void ImportSpineContent (string[] imported, List<string> texturesWithoutMetaFile,
|
|
|
+ bool reimport = false) {
|
|
|
+
|
|
|
var atlasPaths = new List<string>();
|
|
|
var imagePaths = new List<string>();
|
|
|
var skeletonPaths = new List<PathAndProblemInfo>();
|
|
@@ -285,7 +287,7 @@ namespace Spine.Unity.Editor {
|
|
|
if (ap.StartsWith("Packages"))
|
|
|
continue;
|
|
|
TextAsset atlasText = AssetDatabase.LoadAssetAtPath<TextAsset>(ap);
|
|
|
- AtlasAssetBase atlas = IngestSpineAtlas(atlasText);
|
|
|
+ AtlasAssetBase atlas = IngestSpineAtlas(atlasText, texturesWithoutMetaFile);
|
|
|
atlases.Add(atlas);
|
|
|
}
|
|
|
|
|
@@ -428,7 +430,7 @@ namespace Spine.Unity.Editor {
|
|
|
return arr;
|
|
|
}
|
|
|
|
|
|
- static AtlasAssetBase IngestSpineAtlas (TextAsset atlasText) {
|
|
|
+ static AtlasAssetBase IngestSpineAtlas (TextAsset atlasText, List<string> texturesWithoutMetaFile) {
|
|
|
if (atlasText == null) {
|
|
|
Debug.LogWarning("Atlas source cannot be null!");
|
|
|
return null;
|
|
@@ -469,8 +471,9 @@ namespace Spine.Unity.Editor {
|
|
|
for (int i = 0; i < pageFiles.Count; i++) {
|
|
|
string texturePath = assetPath + "/" + pageFiles[i];
|
|
|
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
|
|
|
- if (SpineEditorUtilities.Preferences.setTextureImporterSettings) {
|
|
|
- SetDefaultTextureSettingsIfNew(texturePath, atlasAsset);
|
|
|
+ bool textureIsUninitialized = texturesWithoutMetaFile != null && texturesWithoutMetaFile.Contains(texturePath);
|
|
|
+ if (SpineEditorUtilities.Preferences.setTextureImporterSettings && textureIsUninitialized) {
|
|
|
+ SetDefaultTextureSettings(texturePath, atlasAsset);
|
|
|
}
|
|
|
|
|
|
string pageName = Path.GetFileNameWithoutExtension(pageFiles[i]);
|
|
@@ -546,27 +549,13 @@ namespace Spine.Unity.Editor {
|
|
|
return (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase));
|
|
|
}
|
|
|
|
|
|
- static bool SetDefaultTextureSettingsIfNew (string texturePath, SpineAtlasAsset atlasAsset) {
|
|
|
+ static bool SetDefaultTextureSettings (string texturePath, SpineAtlasAsset atlasAsset) {
|
|
|
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
|
|
if (texImporter == null) {
|
|
|
Debug.LogWarning(string.Format("{0}: Texture asset \"{1}\" not found. Skipping. Please check your atlas file for renamed files.", atlasAsset.name, texturePath));
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- #if UNITY_2018_1_OR_NEWER
|
|
|
- bool customTextureSettingsExist = !texImporter.importSettingsMissing;
|
|
|
- #else
|
|
|
- // unfortunately, importSettingsMissing is not available in Unity 2017,
|
|
|
- // so we check if any settings deviate from Unity's default texture settings.
|
|
|
- bool customTextureSettingsExist = texImporter.mipmapEnabled != true ||
|
|
|
- texImporter.maxTextureSize != 2048 ||
|
|
|
- texImporter.alphaIsTransparency != true ||
|
|
|
- texImporter.wrapMode != TextureWrapMode.Repeat ||
|
|
|
- texImporter.filterMode != FilterMode.Bilinear;
|
|
|
- #endif
|
|
|
- if (customTextureSettingsExist)
|
|
|
- return false;
|
|
|
-
|
|
|
texImporter.textureCompression = TextureImporterCompression.Uncompressed;
|
|
|
texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
|
|
|
texImporter.mipmapEnabled = false;
|