From fcb9980a4b8fa9dc28b8d8f70d2c71ac4b38e38f Mon Sep 17 00:00:00 2001 From: pharan Date: Thu, 20 Jul 2017 14:22:41 +0800 Subject: [PATCH] [unity] Fix runtime AtlasAsset generation. --- .../spine-unity/Asset Types/AtlasAsset.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Asset Types/AtlasAsset.cs b/spine-unity/Assets/spine-unity/Asset Types/AtlasAsset.cs index 5eb5b87f1..80bc8f5e6 100644 --- a/spine-unity/Assets/spine-unity/Asset Types/AtlasAsset.cs +++ b/spine-unity/Assets/spine-unity/Asset Types/AtlasAsset.cs @@ -60,10 +60,7 @@ namespace Spine.Unity { /// /// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. - public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Shader shader, bool initialize) { - if (shader == null) - shader = Shader.Find("Spine/Skeleton"); - + public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Material materialPropertySource, bool initialize) { // Get atlas page names. string atlasString = atlasText.text; atlasString = atlasString.Replace("\r", ""); @@ -84,7 +81,7 @@ namespace Spine.Unity { for (int j = 0, m = textures.Length; j < m; j++) { if (string.Equals(pageName, textures[j].name, System.StringComparison.OrdinalIgnoreCase)) { // Match found. - mat = new Material(shader); + mat = new Material(materialPropertySource); mat.mainTexture = textures[j]; break; } @@ -102,14 +99,12 @@ namespace Spine.Unity { /// /// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. - public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Material materialPropertySource, bool initialize) { - var shader = materialPropertySource.shader; - var oa = CreateRuntimeInstance(atlasText, textures, shader, initialize); + public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Shader shader, bool initialize) { + if (shader == null) + shader = Shader.Find("Spine/Skeleton"); - foreach (var m in oa.materials) { - m.CopyPropertiesFromMaterial(materialPropertySource); - m.shaderKeywords = materialPropertySource.shaderKeywords; - } + Material materialProperySource = new Material(shader); + var oa = CreateRuntimeInstance(atlasText, textures, materialProperySource, initialize); return oa; }