mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[unity] Fix runtime AtlasAsset generation.
This commit is contained in:
parent
972e72848a
commit
fcb9980a4b
@ -60,10 +60,7 @@ namespace Spine.Unity {
|
||||
|
||||
/// <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) {
|
||||
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 {
|
||||
|
||||
/// <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) {
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user