mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Fix runtime AtlasAsset generation.
This commit is contained in:
parent
972e72848a
commit
fcb9980a4b
@ -60,10 +60,7 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.AtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
|
/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.AtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
|
||||||
public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Shader shader, bool initialize) {
|
public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Material materialPropertySource, bool initialize) {
|
||||||
if (shader == null)
|
|
||||||
shader = Shader.Find("Spine/Skeleton");
|
|
||||||
|
|
||||||
// Get atlas page names.
|
// Get atlas page names.
|
||||||
string atlasString = atlasText.text;
|
string atlasString = atlasText.text;
|
||||||
atlasString = atlasString.Replace("\r", "");
|
atlasString = atlasString.Replace("\r", "");
|
||||||
@ -84,7 +81,7 @@ namespace Spine.Unity {
|
|||||||
for (int j = 0, m = textures.Length; j < m; j++) {
|
for (int j = 0, m = textures.Length; j < m; j++) {
|
||||||
if (string.Equals(pageName, textures[j].name, System.StringComparison.OrdinalIgnoreCase)) {
|
if (string.Equals(pageName, textures[j].name, System.StringComparison.OrdinalIgnoreCase)) {
|
||||||
// Match found.
|
// Match found.
|
||||||
mat = new Material(shader);
|
mat = new Material(materialPropertySource);
|
||||||
mat.mainTexture = textures[j];
|
mat.mainTexture = textures[j];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -102,14 +99,12 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.AtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
|
/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.AtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
|
||||||
public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Material materialPropertySource, bool initialize) {
|
public static AtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Shader shader, bool initialize) {
|
||||||
var shader = materialPropertySource.shader;
|
if (shader == null)
|
||||||
var oa = CreateRuntimeInstance(atlasText, textures, shader, initialize);
|
shader = Shader.Find("Spine/Skeleton");
|
||||||
|
|
||||||
foreach (var m in oa.materials) {
|
Material materialProperySource = new Material(shader);
|
||||||
m.CopyPropertiesFromMaterial(materialPropertySource);
|
var oa = CreateRuntimeInstance(atlasText, textures, materialProperySource, initialize);
|
||||||
m.shaderKeywords = materialPropertySource.shaderKeywords;
|
|
||||||
}
|
|
||||||
|
|
||||||
return oa;
|
return oa;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user