From 75d16a4fc976eaf55eff4330858669a0b7bc32b0 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 12 Mar 2019 18:55:00 +0100 Subject: [PATCH] [unity] Improved warnings for incorrect material settings, now not triggering at non-Spine shaders. See #1305. --- .../Editor/SpineEditorUtilities.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs index b27ddb04b..eb2129b39 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/SpineEditorUtilities.cs @@ -266,6 +266,13 @@ namespace Spine.Unity.Editor { if (texImporter == null) { return false; } + + int extensionPos = texturePath.LastIndexOf('.'); + string materialPath = texturePath.Substring(0, extensionPos) + "_Material.mat"; + Material material = AssetDatabase.LoadAssetAtPath(materialPath); + if (material == null || !material.HasProperty(STRAIGHT_ALPHA_PARAM_ID)) { + return true; // non-Spine shader used on material + } // 'sRGBTexture = true' generates incorrectly weighted mipmaps at PMA textures, // causing white borders due to undesired custom weighting. @@ -273,17 +280,10 @@ namespace Spine.Unity.Editor { Debug.LogWarningFormat("`{0}` : Incorrect Texture Settings found: When enabling `Generate Mip Maps`, it is strongly recommended to disable `sRGB (Color Texture)`. Otherwise you will receive white border artifacts on an atlas exported with default `Premultiply alpha` settings.\n(You can disable this warning in `Edit - Preferences - Spine`)", texturePath); } if (texImporter.alphaIsTransparency) { - int extensionPos = texturePath.LastIndexOf('.'); - string materialPath = texturePath.Substring(0, extensionPos) + "_Material.mat"; - Material material = AssetDatabase.LoadAssetAtPath(materialPath); - if (material != null) { - if (material.HasProperty(STRAIGHT_ALPHA_PARAM_ID)) { - int straightAlphaValue = material.GetInt(STRAIGHT_ALPHA_PARAM_ID); - if (straightAlphaValue == 0) { - string materialName = System.IO.Path.GetFileName(materialPath); - Debug.LogWarningFormat("`{0}` and material `{1}` : Incorrect Texture / Material Settings found: It is strongly recommended to disable `Alpha Is Transparency` on `Premultiply alpha` textures.\nAssuming `Premultiply alpha` texture because `Straight Alpha Texture` is disabled at material). (You can disable this warning in `Edit - Preferences - Spine`)", texturePath, materialName); - } - } + int straightAlphaValue = material.GetInt(STRAIGHT_ALPHA_PARAM_ID); + if (straightAlphaValue == 0) { + string materialName = System.IO.Path.GetFileName(materialPath); + Debug.LogWarningFormat("`{0}` and material `{1}` : Incorrect Texture / Material Settings found: It is strongly recommended to disable `Alpha Is Transparency` on `Premultiply alpha` textures.\nAssuming `Premultiply alpha` texture because `Straight Alpha Texture` is disabled at material). (You can disable this warning in `Edit - Preferences - Spine`)", texturePath, materialName); } } return true;