From 39a957c91f1bc39b2e8b68c7593d6c06b420cf25 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 19 Jul 2023 11:37:19 +0200 Subject: [PATCH 1/3] [unity] SkeletonRenderTexture: automatically assigning RenderQuadMaterial upon component reset. --- .../SkeletonRenderTexture/SkeletonRenderTexture.cs | 11 +++++++++++ spine-unity/Assets/Spine Examples/package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTexture.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTexture.cs index 369682ca7..b0c0f26fe 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTexture.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTexture.cs @@ -73,6 +73,17 @@ namespace Spine.Unity.Examples { CreateQuadChild(); } +#if UNITY_EDITOR + protected void Reset () { + string[] folders = { "Assets", "Packages" }; + string[] assets = UnityEditor.AssetDatabase.FindAssets("t:material RenderQuadMaterial", folders); + if (assets.Length > 0) { + string materialPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assets[0]); + quadMaterial = UnityEditor.AssetDatabase.LoadAssetAtPath(materialPath); + } + } +#endif + void CreateQuadChild () { quad = new GameObject(this.name + " RenderTexture", typeof(MeshRenderer), typeof(MeshFilter)); quad.transform.SetParent(this.transform.parent, false); diff --git a/spine-unity/Assets/Spine Examples/package.json b/spine-unity/Assets/Spine Examples/package.json index 08f694f00..2fd21dc34 100644 --- a/spine-unity/Assets/Spine Examples/package.json +++ b/spine-unity/Assets/Spine Examples/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-unity-examples", "displayName": "spine-unity Runtime Examples", "description": "This plugin provides example scenes and scripts for the spine-unity runtime.", - "version": "4.1.12", + "version": "4.1.13", "unity": "2018.3", "author": { "name": "Esoteric Software", From 7b37dd5f7bc85717cc922c68ab6e765e8b866d28 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 19 Jul 2023 17:53:07 +0200 Subject: [PATCH 2/3] [unity] Fixed disabling SkeletonGraphic outside bounds of RectMask2D displaying SkeletonSubmeshGraphic incorrectly. Closes #2324. --- .../Components/Internal/SkeletonSubmeshGraphic.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs index 6bd62bae5..3bab4839b 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Internal/SkeletonSubmeshGraphic.cs @@ -43,5 +43,15 @@ namespace Spine.Unity { protected override void OnPopulateMesh (VertexHelper vh) { vh.Clear(); } + + protected override void OnDisable () { + base.OnDisable(); + this.canvasRenderer.cull = true; + } + + protected override void OnEnable () { + base.OnEnable(); + this.canvasRenderer.cull = false; + } } } From 8900377a89105503fd672295822b8768bc615e7e Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 19 Jul 2023 17:56:18 +0200 Subject: [PATCH 3/3] [unity] Improved robustness of SkeletonGraphic regarding deleting submesh renderer objects and enabling/disabling render separation. --- .../spine-unity/Components/SkeletonGraphic.cs | 31 +++++++++++++++---- spine-unity/Assets/Spine/package.json | 2 +- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs index 7e060a674..55a801270 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs @@ -588,6 +588,13 @@ namespace Spine.Unity { SetRectTransformSize(this, size); this.rectTransform.pivot = p; + foreach (Transform separatorPart in separatorParts) { + RectTransform separatorTransform = separatorPart.GetComponent(); + if (separatorTransform) { + SetRectTransformSize(separatorTransform, size); + separatorTransform.pivot = p; + } + } foreach (SkeletonSubmeshGraphic submeshGraphic in submeshGraphics) { SetRectTransformSize(submeshGraphic, size); submeshGraphic.rectTransform.pivot = p; @@ -595,14 +602,18 @@ namespace Spine.Unity { } public static void SetRectTransformSize (Graphic target, Vector2 size) { + SetRectTransformSize(target.rectTransform, size); + } + + public static void SetRectTransformSize (RectTransform targetRectTransform, Vector2 size) { Vector2 parentSize = Vector2.zero; - if (target.rectTransform.parent != null) { - RectTransform parentTransform = target.rectTransform.parent.GetComponent(); + if (targetRectTransform.parent != null) { + RectTransform parentTransform = targetRectTransform.parent.GetComponent(); if (parentTransform) parentSize = parentTransform.rect.size; } - Vector2 anchorAreaSize = Vector2.Scale(target.rectTransform.anchorMax - target.rectTransform.anchorMin, parentSize); - target.rectTransform.sizeDelta = size - anchorAreaSize; + Vector2 anchorAreaSize = Vector2.Scale(targetRectTransform.anchorMax - targetRectTransform.anchorMin, parentSize); + targetRectTransform.sizeDelta = size - anchorAreaSize; } /// OnAnimationRebuild is raised after the SkeletonAnimation component is successfully initialized. @@ -970,7 +981,7 @@ namespace Spine.Unity { if (i >= usedRenderersCount) canvasRenderer.gameObject.SetActive(true); - if (canvasRenderer.transform.parent != parent.transform) + if (canvasRenderer.transform.parent != parent.transform && !isInRebuild) canvasRenderer.transform.SetParent(parent.transform, false); canvasRenderer.transform.SetSiblingIndex(targetSiblingIndex++); @@ -1007,6 +1018,7 @@ namespace Spine.Unity { for (int i = canvasRenderers.Count - 1; i >= 0; --i) { if (canvasRenderers[i] == null) { canvasRenderers.RemoveAt(i); + submeshGraphics.RemoveAt(i); } } } @@ -1074,7 +1086,14 @@ namespace Spine.Unity { for (int i = currentCount; i < targetCount; ++i) { GameObject go = new GameObject(string.Format("{0}[{1}]", SeparatorPartGameObjectName, i), typeof(RectTransform)); go.transform.SetParent(this.transform, false); - go.transform.localPosition = Vector3.zero; + + RectTransform dstTransform = go.transform.GetComponent(); + dstTransform.localPosition = Vector3.zero; + dstTransform.pivot = rectTransform.pivot; + dstTransform.anchorMin = Vector2.zero; + dstTransform.anchorMax = Vector2.one; + dstTransform.sizeDelta = Vector2.zero; + separatorParts.Add(go.transform); } } diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json index e6c56d0de..be89e2659 100644 --- a/spine-unity/Assets/Spine/package.json +++ b/spine-unity/Assets/Spine/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-unity", "displayName": "spine-unity Runtime", "description": "This plugin provides the spine-unity runtime core.", - "version": "4.1.15", + "version": "4.1.16", "unity": "2018.3", "author": { "name": "Esoteric Software",