mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-05 23:05:01 +08:00
[unity] Fixed SetDefaultTextureSettings not being called on import. Existing texture settings are preserved. Closes #1514.
This commit is contained in:
parent
2031fe14db
commit
d517e32442
@ -469,10 +469,8 @@ 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 &&
|
||||
!System.IO.File.Exists(texturePath + ".meta")) {
|
||||
SetDefaultTextureSettings(texturePath, atlasAsset);
|
||||
if (SpineEditorUtilities.Preferences.setTextureImporterSettings) {
|
||||
SetDefaultTextureSettingsIfNew(texturePath, atlasAsset);
|
||||
}
|
||||
|
||||
string pageName = Path.GetFileNameWithoutExtension(pageFiles[i]);
|
||||
@ -548,13 +546,27 @@ namespace Spine.Unity.Editor {
|
||||
return (AtlasAssetBase)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAssetBase));
|
||||
}
|
||||
|
||||
static bool SetDefaultTextureSettings (string texturePath, SpineAtlasAsset atlasAsset) {
|
||||
static bool SetDefaultTextureSettingsIfNew (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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user