mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Fixed SetDefaultTextureSettings overwriting existing user texture settings when re-importing atlas asset. Closes #1507. Fixed next re-import after moving a spine texture setting material texture to null. Closes #1398. Closes #1397.
This commit is contained in:
parent
2c0881da61
commit
29e0768a84
@ -470,23 +470,9 @@ namespace Spine.Unity.Editor {
|
|||||||
string texturePath = assetPath + "/" + pageFiles[i];
|
string texturePath = assetPath + "/" + pageFiles[i];
|
||||||
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
|
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
|
||||||
|
|
||||||
if (SpineEditorUtilities.Preferences.setTextureImporterSettings) {
|
if (SpineEditorUtilities.Preferences.setTextureImporterSettings &&
|
||||||
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
!System.IO.File.Exists(texturePath + ".meta")) {
|
||||||
if (texImporter == null) {
|
SetDefaultTextureSettings(texturePath, atlasAsset);
|
||||||
Debug.LogWarning(string.Format("{0} ::: Texture asset \"{1}\" not found. Skipping. Please check your atlas file for renamed files.", atlasAsset.name, texturePath));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
texImporter.textureCompression = TextureImporterCompression.Uncompressed;
|
|
||||||
texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
|
|
||||||
texImporter.mipmapEnabled = false;
|
|
||||||
texImporter.alphaIsTransparency = false; // Prevent the texture importer from applying bleed to the transparent parts for PMA.
|
|
||||||
texImporter.spriteImportMode = SpriteImportMode.None;
|
|
||||||
texImporter.maxTextureSize = 2048;
|
|
||||||
|
|
||||||
EditorUtility.SetDirty(texImporter);
|
|
||||||
AssetDatabase.ImportAsset(texturePath);
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string pageName = Path.GetFileNameWithoutExtension(pageFiles[i]);
|
string pageName = Path.GetFileNameWithoutExtension(pageFiles[i]);
|
||||||
@ -505,7 +491,9 @@ namespace Spine.Unity.Editor {
|
|||||||
vestigialMaterials.Remove(mat);
|
vestigialMaterials.Remove(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
mat.mainTexture = texture;
|
if (texture != null)
|
||||||
|
mat.mainTexture = texture;
|
||||||
|
|
||||||
EditorUtility.SetDirty(mat);
|
EditorUtility.SetDirty(mat);
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
|
||||||
@ -559,6 +547,26 @@ namespace Spine.Unity.Editor {
|
|||||||
protectFromStackGarbageCollection.Remove(atlasAsset);
|
protectFromStackGarbageCollection.Remove(atlasAsset);
|
||||||
return (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase));
|
return (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
texImporter.textureCompression = TextureImporterCompression.Uncompressed;
|
||||||
|
texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
|
||||||
|
texImporter.mipmapEnabled = false;
|
||||||
|
texImporter.alphaIsTransparency = false; // Prevent the texture importer from applying bleed to the transparent parts for PMA.
|
||||||
|
texImporter.spriteImportMode = SpriteImportMode.None;
|
||||||
|
texImporter.maxTextureSize = 2048;
|
||||||
|
|
||||||
|
EditorUtility.SetDirty(texImporter);
|
||||||
|
AssetDatabase.ImportAsset(texturePath);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Import SkeletonData (json or binary)
|
#region Import SkeletonData (json or binary)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user