mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge branch '4.1' into 4.2-beta
This commit is contained in:
commit
764a480610
@ -116,6 +116,7 @@ namespace Spine.Unity {
|
|||||||
public bool updateSeparatorPartLocation = true;
|
public bool updateSeparatorPartLocation = true;
|
||||||
|
|
||||||
private bool wasUpdatedAfterInit = true;
|
private bool wasUpdatedAfterInit = true;
|
||||||
|
private bool requiresInstructionUpate = true;
|
||||||
private Texture baseTexture = null;
|
private Texture baseTexture = null;
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@ -308,7 +309,10 @@ namespace Spine.Unity {
|
|||||||
public override void Rebuild (CanvasUpdate update) {
|
public override void Rebuild (CanvasUpdate update) {
|
||||||
base.Rebuild(update);
|
base.Rebuild(update);
|
||||||
if (canvasRenderer.cull) return;
|
if (canvasRenderer.cull) return;
|
||||||
if (update == CanvasUpdate.PreRender) UpdateMeshToInstructions();
|
if (update == CanvasUpdate.PreRender) {
|
||||||
|
if (requiresInstructionUpate) PrepareInstructionsAndRenderers(isInRebuild: true);
|
||||||
|
UpdateMeshToInstructions();
|
||||||
|
}
|
||||||
if (allowMultipleCanvasRenderers) canvasRenderer.Clear();
|
if (allowMultipleCanvasRenderers) canvasRenderer.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,8 +408,7 @@ namespace Spine.Unity {
|
|||||||
if (updateMode != UpdateMode.FullUpdate) return;
|
if (updateMode != UpdateMode.FullUpdate) return;
|
||||||
|
|
||||||
PrepareInstructionsAndRenderers();
|
PrepareInstructionsAndRenderers();
|
||||||
if (OnInstructionsPrepared != null)
|
|
||||||
OnInstructionsPrepared(this.currentInstructions);
|
|
||||||
SetVerticesDirty(); // triggers Rebuild and avoids potential double-update in a single frame
|
SetVerticesDirty(); // triggers Rebuild and avoids potential double-update in a single frame
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,9 +455,11 @@ namespace Spine.Unity {
|
|||||||
public Skeleton Skeleton {
|
public Skeleton Skeleton {
|
||||||
get {
|
get {
|
||||||
Initialize(false);
|
Initialize(false);
|
||||||
|
requiresInstructionUpate = true;
|
||||||
return skeleton;
|
return skeleton;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
requiresInstructionUpate = true;
|
||||||
skeleton = value;
|
skeleton = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -690,11 +695,12 @@ namespace Spine.Unity {
|
|||||||
OnAnimationRebuild(this);
|
OnAnimationRebuild(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrepareInstructionsAndRenderers () {
|
public void PrepareInstructionsAndRenderers (bool isInRebuild = false) {
|
||||||
|
requiresInstructionUpate = false;
|
||||||
if (!this.allowMultipleCanvasRenderers) {
|
if (!this.allowMultipleCanvasRenderers) {
|
||||||
MeshGenerator.GenerateSingleSubmeshInstruction(currentInstructions, skeleton, null);
|
MeshGenerator.GenerateSingleSubmeshInstruction(currentInstructions, skeleton, null);
|
||||||
if (canvasRenderers.Count > 0)
|
if (canvasRenderers.Count > 0)
|
||||||
DisableUnusedCanvasRenderers(usedCount: 0);
|
DisableUnusedCanvasRenderers(usedCount: 0, isInRebuild: isInRebuild);
|
||||||
usedRenderersCount = 0;
|
usedRenderersCount = 0;
|
||||||
} else {
|
} else {
|
||||||
MeshGenerator.GenerateSkeletonRendererInstruction(currentInstructions, skeleton, null,
|
MeshGenerator.GenerateSkeletonRendererInstruction(currentInstructions, skeleton, null,
|
||||||
@ -707,8 +713,10 @@ namespace Spine.Unity {
|
|||||||
EnsureMeshesCount(submeshCount);
|
EnsureMeshesCount(submeshCount);
|
||||||
EnsureUsedTexturesAndMaterialsCount(submeshCount);
|
EnsureUsedTexturesAndMaterialsCount(submeshCount);
|
||||||
EnsureSeparatorPartCount();
|
EnsureSeparatorPartCount();
|
||||||
PrepareRendererGameObjects(currentInstructions);
|
PrepareRendererGameObjects(currentInstructions, isInRebuild);
|
||||||
}
|
}
|
||||||
|
if (OnInstructionsPrepared != null)
|
||||||
|
OnInstructionsPrepared(this.currentInstructions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateMesh () {
|
public void UpdateMesh () {
|
||||||
@ -922,9 +930,11 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void PrepareRendererGameObjects (SkeletonRendererInstruction currentInstructions) {
|
protected void PrepareRendererGameObjects (SkeletonRendererInstruction currentInstructions,
|
||||||
|
bool isInRebuild = false) {
|
||||||
|
|
||||||
int submeshCount = currentInstructions.submeshInstructions.Count;
|
int submeshCount = currentInstructions.submeshInstructions.Count;
|
||||||
DisableUnusedCanvasRenderers(usedCount: submeshCount);
|
DisableUnusedCanvasRenderers(usedCount: submeshCount, isInRebuild: isInRebuild);
|
||||||
|
|
||||||
int separatorSlotGroupIndex = 0;
|
int separatorSlotGroupIndex = 0;
|
||||||
int targetSiblingIndex = 0;
|
int targetSiblingIndex = 0;
|
||||||
@ -961,13 +971,14 @@ namespace Spine.Unity {
|
|||||||
usedRenderersCount = submeshCount;
|
usedRenderersCount = submeshCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void DisableUnusedCanvasRenderers (int usedCount) {
|
protected void DisableUnusedCanvasRenderers (int usedCount, bool isInRebuild = false) {
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
RemoveNullCanvasRenderers();
|
RemoveNullCanvasRenderers();
|
||||||
#endif
|
#endif
|
||||||
for (int i = usedCount; i < canvasRenderers.Count; i++) {
|
for (int i = usedCount; i < canvasRenderers.Count; i++) {
|
||||||
canvasRenderers[i].Clear();
|
canvasRenderers[i].Clear();
|
||||||
canvasRenderers[i].gameObject.SetActive(false);
|
if (!isInRebuild) // rebuild does not allow disabling Graphic and thus removing it from rebuild list.
|
||||||
|
canvasRenderers[i].gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -819,8 +819,8 @@ namespace Spine.Unity {
|
|||||||
b2.x *= alpha;
|
b2.x *= alpha;
|
||||||
b2.y = slot.Data.BlendMode == BlendMode.Additive ? 0 : alpha;
|
b2.y = slot.Data.BlendMode == BlendMode.Additive ? 0 : alpha;
|
||||||
}
|
}
|
||||||
int meshVertexCount = meshAttachment.WorldVerticesLength;
|
int verticesArrayLength = meshAttachment.WorldVerticesLength;
|
||||||
for (int iii = 0; iii < meshVertexCount; iii += 2) {
|
for (int iii = 0; iii < verticesArrayLength; iii += 2) {
|
||||||
uv2i[vi] = rg;
|
uv2i[vi] = rg;
|
||||||
uv3i[vi] = b2;
|
uv3i[vi] = b2;
|
||||||
vi++;
|
vi++;
|
||||||
@ -892,8 +892,8 @@ namespace Spine.Unity {
|
|||||||
} else { //if (settings.renderMeshes) {
|
} else { //if (settings.renderMeshes) {
|
||||||
MeshAttachment meshAttachment = attachment as MeshAttachment;
|
MeshAttachment meshAttachment = attachment as MeshAttachment;
|
||||||
if (meshAttachment != null) {
|
if (meshAttachment != null) {
|
||||||
int meshVertexCount = meshAttachment.WorldVerticesLength;
|
int verticesArrayLength = meshAttachment.WorldVerticesLength;
|
||||||
if (tempVerts.Length < meshVertexCount) this.tempVerts = tempVerts = new float[meshVertexCount];
|
if (tempVerts.Length < verticesArrayLength) this.tempVerts = tempVerts = new float[verticesArrayLength];
|
||||||
meshAttachment.ComputeWorldVertices(slot, tempVerts);
|
meshAttachment.ComputeWorldVertices(slot, tempVerts);
|
||||||
|
|
||||||
if (settings.pmaVertexColors) {
|
if (settings.pmaVertexColors) {
|
||||||
@ -923,7 +923,7 @@ namespace Spine.Unity {
|
|||||||
if (fy > bmax.y) bmax.y = fy;
|
if (fy > bmax.y) bmax.y = fy;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int iii = 0; iii < meshVertexCount; iii += 2) {
|
for (int iii = 0; iii < verticesArrayLength; iii += 2) {
|
||||||
float x = tempVerts[iii], y = tempVerts[iii + 1];
|
float x = tempVerts[iii], y = tempVerts[iii + 1];
|
||||||
vbi[vertexIndex].x = x; vbi[vertexIndex].y = y; vbi[vertexIndex].z = z;
|
vbi[vertexIndex].x = x; vbi[vertexIndex].y = y; vbi[vertexIndex].z = z;
|
||||||
cbi[vertexIndex] = color; ubi[vertexIndex].x = attachmentUVs[iii]; ubi[vertexIndex].y = attachmentUVs[iii + 1];
|
cbi[vertexIndex] = color; ubi[vertexIndex].x = attachmentUVs[iii]; ubi[vertexIndex].y = attachmentUVs[iii + 1];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user