Merge branch '4.1' into 4.2-beta

This commit is contained in:
Harald Csaszar 2023-08-21 18:56:44 +02:00
commit 22770247c0

View File

@ -955,42 +955,52 @@ namespace Spine.Unity {
int submeshCount = currentInstructions.submeshInstructions.Count; int submeshCount = currentInstructions.submeshInstructions.Count;
DisableUnusedCanvasRenderers(usedCount: submeshCount, isInRebuild: isInRebuild); DisableUnusedCanvasRenderers(usedCount: submeshCount, isInRebuild: isInRebuild);
int separatorSlotGroupIndex = 0; Transform parent = this.separatorParts.Count == 0 ? this.transform : this.separatorParts[0];
int targetSiblingIndex = 0;
Transform parent = this.separatorSlots.Count == 0 ? this.transform : this.separatorParts[0];
if (updateSeparatorPartLocation) { if (updateSeparatorPartLocation) {
for (int p = 0; p < this.separatorParts.Count; ++p) { for (int p = 0; p < this.separatorParts.Count; ++p) {
separatorParts[p].position = this.transform.position; Transform separatorPart = separatorParts[p];
separatorParts[p].rotation = this.transform.rotation; if (separatorPart == null) continue;
separatorPart.position = this.transform.position;
separatorPart.rotation = this.transform.rotation;
} }
} }
if (updateSeparatorPartScale) { if (updateSeparatorPartScale) {
Vector3 targetScale = this.transform.lossyScale; Vector3 targetScale = this.transform.lossyScale;
for (int p = 0; p < this.separatorParts.Count; ++p) { for (int p = 0; p < this.separatorParts.Count; ++p) {
Transform partParent = separatorParts[p].transform.parent; Transform separatorPart = separatorParts[p];
if (separatorPart == null) continue;
Transform partParent = separatorPart.parent;
Vector3 parentScale = partParent == null ? Vector3.one : partParent.lossyScale; Vector3 parentScale = partParent == null ? Vector3.one : partParent.lossyScale;
separatorParts[p].localScale = new Vector3( separatorPart.localScale = new Vector3(
parentScale.x == 0f ? 1f : targetScale.x / parentScale.x, parentScale.x == 0f ? 1f : targetScale.x / parentScale.x,
parentScale.y == 0f ? 1f : targetScale.y / parentScale.y, parentScale.y == 0f ? 1f : targetScale.y / parentScale.y,
parentScale.z == 0f ? 1f : targetScale.z / parentScale.z); parentScale.z == 0f ? 1f : targetScale.z / parentScale.z);
} }
} }
int separatorSlotGroupIndex = 0;
int targetSiblingIndex = 0;
for (int i = 0; i < submeshCount; i++) { for (int i = 0; i < submeshCount; i++) {
CanvasRenderer canvasRenderer = canvasRenderers[i]; CanvasRenderer canvasRenderer = canvasRenderers[i];
if (i >= usedRenderersCount) if (canvasRenderer != null) {
canvasRenderer.gameObject.SetActive(true); if (i >= usedRenderersCount)
canvasRenderer.gameObject.SetActive(true);
if (canvasRenderer.transform.parent != parent.transform && !isInRebuild) if (canvasRenderer.transform.parent != parent.transform && !isInRebuild)
canvasRenderer.transform.SetParent(parent.transform, false); canvasRenderer.transform.SetParent(parent.transform, false);
canvasRenderer.transform.SetSiblingIndex(targetSiblingIndex++); canvasRenderer.transform.SetSiblingIndex(targetSiblingIndex++);
RectTransform dstTransform = submeshGraphics[i].rectTransform; }
dstTransform.localPosition = Vector3.zero;
dstTransform.pivot = rectTransform.pivot; SkeletonSubmeshGraphic submeshGraphic = submeshGraphics[i];
dstTransform.anchorMin = Vector2.zero; if (submeshGraphic != null) {
dstTransform.anchorMax = Vector2.one; RectTransform dstTransform = submeshGraphic.rectTransform;
dstTransform.sizeDelta = Vector2.zero; dstTransform.localPosition = Vector3.zero;
dstTransform.pivot = rectTransform.pivot;
dstTransform.anchorMin = Vector2.zero;
dstTransform.anchorMax = Vector2.one;
dstTransform.sizeDelta = Vector2.zero;
}
SubmeshInstruction submeshInstructionItem = currentInstructions.submeshInstructions.Items[i]; SubmeshInstruction submeshInstructionItem = currentInstructions.submeshInstructions.Items[i];
if (submeshInstructionItem.forceSeparate) { if (submeshInstructionItem.forceSeparate) {