From 2fad7075296563ec8477e608d0a5760e50e12178 Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 9 Apr 2018 20:37:16 +0800 Subject: [PATCH] [unity] Update API use and compatibility notes to 3.7. --- .../Components/SkeletonAnimator.cs | 12 +-- .../Components/SkeletonRenderer.cs | 1 + .../spine-unity/Editor/SkeletonBaker.cs | 20 ++-- .../Editor/SkeletonDataAssetInspector.cs | 11 ++- .../spine-unity/Editor/SkeletonDebugWindow.cs | 2 +- .../Editor/SpineEditorUtilities.cs | 4 +- .../spine-unity/Mesh Generation/SpineMesh.cs | 94 ++++++++++--------- .../AttachmentTools/AttachmentTools.cs | 6 +- .../SkeletonGraphic/SkeletonGraphic.cs | 1 + .../SkeletonPartsRenderer.cs | 1 + .../SkeletonUtilityKinematicShadow.cs | 23 ++++- .../Assets/spine-unity/SkeletonExtensions.cs | 6 +- spine-unity/Assets/spine-unity/version.txt | 2 +- 13 files changed, 103 insertions(+), 80 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Components/SkeletonAnimator.cs b/spine-unity/Assets/spine-unity/Components/SkeletonAnimator.cs index c9d0c4da6..91a1c430d 100644 --- a/spine-unity/Assets/spine-unity/Components/SkeletonAnimator.cs +++ b/spine-unity/Assets/spine-unity/Components/SkeletonAnimator.cs @@ -201,12 +201,12 @@ namespace Spine.Unity { // Always use Mix instead of Applying the first non-zero weighted clip. for (int c = 0; c < clipInfoCount; c++) { var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; - animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, MixPose.Current, MixDirection.In); + animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, MixBlend.Replace, MixDirection.In); } if (hasNext) { for (int c = 0; c < nextClipInfoCount; c++) { var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; - animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, MixPose.Current, MixDirection.In); + animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, MixBlend.Replace, MixDirection.In); } } } else { // case MixNext || SpineStyle @@ -214,13 +214,13 @@ namespace Spine.Unity { int c = 0; for (; c < clipInfoCount; c++) { var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; - animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, 1f, MixPose.Current, MixDirection.In); + animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, 1f, MixBlend.Replace, MixDirection.In); break; } // Mix the rest for (; c < clipInfoCount; c++) { var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; - animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, MixPose.Current, MixDirection.In); + animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, MixBlend.Replace, MixDirection.In); } c = 0; @@ -229,14 +229,14 @@ namespace Spine.Unity { if (mode == MixMode.SpineStyle) { for (; c < nextClipInfoCount; c++) { var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; - animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, MixPose.Current, MixDirection.In); + animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, MixBlend.Replace, MixDirection.In); break; } } // Mix the rest for (; c < nextClipInfoCount; c++) { var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue; - animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, MixPose.Current, MixDirection.In); + animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime , info.clip.length,nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, MixBlend.Replace, MixDirection.In); } } } diff --git a/spine-unity/Assets/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/spine-unity/Components/SkeletonRenderer.cs index fbce68644..811cfcb92 100644 --- a/spine-unity/Assets/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/spine-unity/Components/SkeletonRenderer.cs @@ -317,6 +317,7 @@ namespace Spine.Unity { meshRenderer.sharedMaterials = rendererBuffers.GetUpdatedSharedMaterialsArray(); } + meshGenerator.FillLateVertexData(currentMesh); // STEP 4. The UnityEngine.Mesh is ready. Set it as the MeshFilter's mesh. Store the instructions used for that mesh. =========== meshFilter.sharedMesh = currentMesh; diff --git a/spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs b/spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs index b9e04b5a0..c85e6a5ee 100644 --- a/spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs +++ b/spine-unity/Assets/spine-unity/Editor/SkeletonBaker.cs @@ -1053,7 +1053,7 @@ namespace Spine.Unity.Editor { currentTime = time; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); lastTime = time; listIndex++; @@ -1080,7 +1080,7 @@ namespace Spine.Unity.Editor { currentTime = time; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); lastTime = time; listIndex++; @@ -1099,7 +1099,7 @@ namespace Spine.Unity.Editor { if (i == steps) currentTime = time; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); px = xKeys[listIndex - 1]; py = yKeys[listIndex - 1]; @@ -1196,7 +1196,7 @@ namespace Spine.Unity.Editor { currentTime = time; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); lastTime = time; listIndex++; @@ -1223,7 +1223,7 @@ namespace Spine.Unity.Editor { currentTime = time; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); lastTime = time; listIndex++; @@ -1241,7 +1241,7 @@ namespace Spine.Unity.Editor { if (i == steps) currentTime = time; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); px = xKeys[listIndex - 1]; py = yKeys[listIndex - 1]; @@ -1325,7 +1325,7 @@ namespace Spine.Unity.Editor { currentTime = time; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); lastTime = time; listIndex++; @@ -1350,7 +1350,7 @@ namespace Spine.Unity.Editor { currentTime = time; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); lastTime = time; listIndex++; @@ -1360,7 +1360,7 @@ namespace Spine.Unity.Editor { float time = frames[f]; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); skeleton.UpdateWorldTransform(); rotation = frames[f + 1] + boneData.Rotation; @@ -1374,7 +1374,7 @@ namespace Spine.Unity.Editor { if (i == steps) currentTime = time; - timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixPose.Setup, MixDirection.In); + timeline.Apply(skeleton, lastTime, currentTime, null, 1, MixBlend.Setup, MixDirection.In); skeleton.UpdateWorldTransform(); pk = keys[listIndex - 1]; diff --git a/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs b/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs index 750f56855..8216151ad 100644 --- a/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs +++ b/spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs @@ -370,9 +370,9 @@ namespace Spine.Unity.Editor { } EditorGUILayout.LabelField("Name", " Duration"); - bool nonessential = targetSkeletonData.ImagesPath != null; // Currently the only way to determine if skeleton data has nonessential data. (Spine 3.6) - float fps = targetSkeletonData.Fps; - if (nonessential && fps == 0) fps = 30; + //bool nonessential = targetSkeletonData.ImagesPath != null; // Currently the only way to determine if skeleton data has nonessential data. (Spine 3.6) + //float fps = targetSkeletonData.Fps; + //if (nonessential && fps == 0) fps = 30; var activeTrack = preview.ActiveTrack; foreach (Animation animation in targetSkeletonData.Animations) { @@ -387,8 +387,9 @@ namespace Spine.Unity.Editor { } else { GUILayout.Label("-", GUILayout.Width(24)); } - string frameCountString = (fps > 0) ? ("(" + (Mathf.RoundToInt(animation.Duration * fps)) + ")").PadLeft(12, ' ') : string.Empty; - EditorGUILayout.LabelField(new GUIContent(animation.Name, Icons.animation), SpineInspectorUtility.TempContent(animation.Duration.ToString("f3") + "s" + frameCountString)); + //string frameCountString = (fps > 0) ? ("(" + (Mathf.RoundToInt(animation.Duration * fps)) + ")").PadLeft(12, ' ') : string.Empty; + //EditorGUILayout.LabelField(new GUIContent(animation.Name, Icons.animation), SpineInspectorUtility.TempContent(animation.Duration.ToString("f3") + "s" + frameCountString)); + EditorGUILayout.LabelField(new GUIContent(animation.Name, Icons.animation), SpineInspectorUtility.TempContent(animation.Duration.ToString("f3") + "s")); } } } diff --git a/spine-unity/Assets/spine-unity/Editor/SkeletonDebugWindow.cs b/spine-unity/Assets/spine-unity/Editor/SkeletonDebugWindow.cs index ac9e02f1a..cee6ecf9f 100644 --- a/spine-unity/Assets/spine-unity/Editor/SkeletonDebugWindow.cs +++ b/spine-unity/Assets/spine-unity/Editor/SkeletonDebugWindow.cs @@ -374,7 +374,7 @@ namespace Spine.Unity.Editor { EditorGUI.BeginChangeCheck(); c.Mix = EditorGUILayout.Slider("Mix", c.Mix, MixMin, MixMax); - c.BendDirection = EditorGUILayout.Toggle("Bend Direction +", c.BendDirection > 0) ? 1 : -1; + c.BendDirection = EditorGUILayout.Toggle(SpineInspectorUtility.TempContent("Bend Clockwise", tooltip: "IkConstraint.BendDirection == 1 if clockwise; -1 if counterclockwise."), c.BendDirection > 0) ? 1 : -1; if (EditorGUI.EndChangeCheck()) requireRepaint = true; EditorGUILayout.Space(); diff --git a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs index c87e493a4..59166cd68 100644 --- a/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs +++ b/spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs @@ -1240,8 +1240,8 @@ namespace Spine.Unity.Editor { #endregion #region Checking Methods - static int[][] compatibleBinaryVersions = { new[] {3, 6, 0}, new[] {3, 5, 0} }; - static int[][] compatibleJsonVersions = { new[] { 3, 6, 0 }, new[] { 3, 7, 0 }, new[] { 3, 5, 0 } }; + static int[][] compatibleBinaryVersions = { new[] {3, 7, 0} }; + static int[][] compatibleJsonVersions = { new[] { 3, 7, 0 }, new[] { 3, 6, 0 }, new[] { 3, 5, 0 } }; //static bool isFixVersionRequired = false; static bool CheckForValidSkeletonData (string skeletonJSONPath) { diff --git a/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs b/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs index 40be3a896..b3dd4b763 100644 --- a/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs +++ b/spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs @@ -50,13 +50,13 @@ namespace Spine.Unity { } } - /// Instructions for how to generate a mesh or submesh out of a range of slots in a given skeleton. + /// Instructions for how to generate a mesh or submesh: "Render this skeleton's slots: start slot, up to but not including endSlot, using this material." public struct SubmeshInstruction { public Skeleton skeleton; public int startSlot; public int endSlot; - public Material material; + public bool forceSeparate; public int preActiveClippingSlotSource; @@ -206,35 +206,35 @@ namespace Spine.Unity { bool skeletonHasClipping = false; var drawOrderItems = drawOrder.Items; for (int i = 0; i < drawOrderCount; i++) { - Slot slot = drawOrderItems[i]; - Attachment attachment = slot.attachment; + Slot slot = drawOrderItems[i]; + Attachment attachment = slot.attachment; - workingAttachmentsItems[i] = attachment; - int attachmentTriangleCount; - int attachmentVertexCount; + workingAttachmentsItems[i] = attachment; + int attachmentTriangleCount; + int attachmentVertexCount; - var regionAttachment = attachment as RegionAttachment; - if (regionAttachment != null) { - attachmentVertexCount = 4; - attachmentTriangleCount = 6; - } else { - var meshAttachment = attachment as MeshAttachment; - if (meshAttachment != null) { - attachmentVertexCount = meshAttachment.worldVerticesLength >> 1; - attachmentTriangleCount = meshAttachment.triangles.Length; - } else { - var clippingAttachment = attachment as ClippingAttachment; - if (clippingAttachment != null) { - current.hasClipping = true; - skeletonHasClipping = true; - } - attachmentVertexCount = 0; - attachmentTriangleCount = 0; - } - } - current.rawTriangleCount += attachmentTriangleCount; - current.rawVertexCount += attachmentVertexCount; - totalRawVertexCount += attachmentVertexCount; + var regionAttachment = attachment as RegionAttachment; + if (regionAttachment != null) { + attachmentVertexCount = 4; + attachmentTriangleCount = 6; + } else { + var meshAttachment = attachment as MeshAttachment; + if (meshAttachment != null) { + attachmentVertexCount = meshAttachment.worldVerticesLength >> 1; + attachmentTriangleCount = meshAttachment.triangles.Length; + } else { + var clippingAttachment = attachment as ClippingAttachment; + if (clippingAttachment != null) { + current.hasClipping = true; + skeletonHasClipping = true; + } + attachmentVertexCount = 0; + attachmentTriangleCount = 0; + } + } + current.rawTriangleCount += attachmentTriangleCount; + current.rawVertexCount += attachmentVertexCount; + totalRawVertexCount += attachmentVertexCount; } @@ -448,9 +448,9 @@ namespace Spine.Unity { meshBoundsThickness = 0f; } - submeshes.Count = 1; - submeshes.Items[0].Clear(false); submeshIndex = 0; + submeshes.Count = 1; + //submeshes.Items[0].Clear(false); } public void AddSubmesh (SubmeshInstruction instruction, bool updateTriangles = true) { @@ -500,7 +500,7 @@ namespace Spine.Unity { int attachmentIndexCount; Color c = default(Color); - + // Identify and prepare values. var region = attachment as RegionAttachment; if (region != null) { @@ -969,8 +969,6 @@ namespace Spine.Unity { var vbi = vertexBuffer.Items; var ubi = uvBuffer.Items; var cbi = colorBuffer.Items; - var sbi = submeshes.Items; - int submeshCount = submeshes.Count; // Zero the extra. { @@ -1020,18 +1018,26 @@ namespace Spine.Unity { if (settings.tintBlack) { mesh.uv2 = this.uv2.Items; mesh.uv3 = this.uv3.Items; - } + } + } + } - if (settings.calculateTangents) { - MeshGenerator.SolveTangents2DEnsureSize(ref this.tangents, ref this.tempTanBuffer, vertexCount); - for (int i = 0; i < submeshCount; i++) { - var submesh = sbi[i].Items; - int triangleCount = sbi[i].Count; - MeshGenerator.SolveTangents2DTriangles(this.tempTanBuffer, submesh, triangleCount, vbi, ubi, vertexCount); - } - MeshGenerator.SolveTangents2DBuffer(this.tangents, this.tempTanBuffer, vertexCount); - mesh.tangents = this.tangents; + public void FillLateVertexData (Mesh mesh) { + if (settings.calculateTangents) { + int vertexCount = this.vertexBuffer.Count; + var sbi = submeshes.Items; + int submeshCount = submeshes.Count; + var vbi = vertexBuffer.Items; + var ubi = uvBuffer.Items; + + MeshGenerator.SolveTangents2DEnsureSize(ref this.tangents, ref this.tempTanBuffer, vertexCount); + for (int i = 0; i < submeshCount; i++) { + var submesh = sbi[i].Items; + int triangleCount = sbi[i].Count; + MeshGenerator.SolveTangents2DTriangles(this.tempTanBuffer, submesh, triangleCount, vbi, ubi, vertexCount); } + MeshGenerator.SolveTangents2DBuffer(this.tangents, this.tempTanBuffer, vertexCount); + mesh.tangents = this.tangents; } } diff --git a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs index 265e9c7d9..7d0b2d0e1 100644 --- a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs +++ b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs @@ -792,16 +792,16 @@ namespace Spine.Unity.Modules.AttachmentTools { /// Adds an attachment to the skin for the specified slot index and name. If the name already exists for the slot, the previous value is replaced. public static void SetAttachment (this Skin skin, string slotName, string keyName, Attachment attachment, Skeleton skeleton) { - if (skeleton == null) throw new System.ArgumentNullException("skeleton", "skeleton cannot be null."); int slotIndex = skeleton.FindSlotIndex(slotName); + if (skeleton == null) throw new System.ArgumentNullException("skeleton", "skeleton cannot be null."); if (slotIndex == -1) throw new System.ArgumentException(string.Format("Slot '{0}' does not exist in skeleton.", slotName), "slotName"); skin.AddAttachment(slotIndex, keyName, attachment); } /// Gets an attachment from the skin for the specified slot index and name. public static Attachment GetAttachment (this Skin skin, string slotName, string keyName, Skeleton skeleton) { - if (skeleton == null) throw new System.ArgumentNullException("skeleton", "skeleton cannot be null."); int slotIndex = skeleton.FindSlotIndex(slotName); + if (skeleton == null) throw new System.ArgumentNullException("skeleton", "skeleton cannot be null."); if (slotIndex == -1) throw new System.ArgumentException(string.Format("Slot '{0}' does not exist in skeleton.", slotName), "slotName"); return skin.GetAttachment(slotIndex, keyName); } @@ -813,8 +813,8 @@ namespace Spine.Unity.Modules.AttachmentTools { /// Removes the attachment. Returns true if the element is successfully found and removed; otherwise, false. public static bool RemoveAttachment (this Skin skin, string slotName, string keyName, Skeleton skeleton) { - if (skeleton == null) throw new System.ArgumentNullException("skeleton", "skeleton cannot be null."); int slotIndex = skeleton.FindSlotIndex(slotName); + if (skeleton == null) throw new System.ArgumentNullException("skeleton", "skeleton cannot be null."); if (slotIndex == -1) throw new System.ArgumentException(string.Format("Slot '{0}' does not exist in skeleton.", slotName), "slotName"); return skin.RemoveAttachment(slotIndex, keyName); } diff --git a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs b/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs index 3e04344b0..622f21c15 100644 --- a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs +++ b/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs @@ -287,6 +287,7 @@ namespace Spine.Unity { var mesh = smartMesh.mesh; meshGenerator.FillVertexData(mesh); if (updateTriangles) meshGenerator.FillTrianglesSingle(mesh); + meshGenerator.FillLateVertexData(mesh); canvasRenderer.SetMesh(mesh); smartMesh.instructionUsed.Set(currentInstructions); diff --git a/spine-unity/Assets/spine-unity/Modules/SkeletonRenderSeparator/SkeletonPartsRenderer.cs b/spine-unity/Assets/spine-unity/Modules/SkeletonRenderSeparator/SkeletonPartsRenderer.cs index f1fc26685..6660bea93 100644 --- a/spine-unity/Assets/spine-unity/Modules/SkeletonRenderSeparator/SkeletonPartsRenderer.cs +++ b/spine-unity/Assets/spine-unity/Modules/SkeletonRenderSeparator/SkeletonPartsRenderer.cs @@ -117,6 +117,7 @@ namespace Spine.Unity.Modules { meshRenderer.sharedMaterials = buffers.GetUpdatedSharedMaterialsArray(); } } + meshGenerator.FillLateVertexData(mesh); meshFilter.sharedMesh = mesh; smartMesh.instructionUsed.Set(currentInstructions); diff --git a/spine-unity/Assets/spine-unity/Modules/SkeletonUtility Modules/SkeletonUtilityKinematicShadow.cs b/spine-unity/Assets/spine-unity/Modules/SkeletonUtility Modules/SkeletonUtilityKinematicShadow.cs index 4389bec40..447d37fe0 100644 --- a/spine-unity/Assets/spine-unity/Modules/SkeletonUtility Modules/SkeletonUtilityKinematicShadow.cs +++ b/spine-unity/Assets/spine-unity/Modules/SkeletonUtility Modules/SkeletonUtilityKinematicShadow.cs @@ -41,6 +41,7 @@ namespace Spine.Unity.Modules { public bool detachedShadow = false; public Transform parent; public bool hideShadow = true; + public PhysicsSystem physicsSystem = PhysicsSystem.Physics3D; #endregion GameObject shadowRoot; @@ -49,6 +50,11 @@ namespace Spine.Unity.Modules { public Transform dest, src; } + public enum PhysicsSystem { + Physics2D, + Physics3D + }; + void Start () { // Duplicate this gameObject as the "shadow" with a different parent. shadowRoot = Instantiate(this.gameObject); @@ -84,9 +90,10 @@ namespace Spine.Unity.Modules { foreach (var b in bones) { if (b.gameObject == this.gameObject) continue; - + + System.Type checkType = (physicsSystem == PhysicsSystem.Physics2D) ? typeof(Rigidbody2D) : typeof(Rigidbody); foreach (var sb in shadowBones) { - if (sb.GetComponent() != null && sb.boneName == b.boneName) { + if (sb.GetComponent(checkType) != null && sb.boneName == b.boneName) { shadowTable.Add(new TransformPair { dest = b.transform, src = sb.transform @@ -111,9 +118,15 @@ namespace Spine.Unity.Modules { } void FixedUpdate () { - var shadowRootRigidbody = shadowRoot.GetComponent(); - shadowRootRigidbody.MovePosition(transform.position); - shadowRootRigidbody.MoveRotation(transform.rotation); + if (physicsSystem == PhysicsSystem.Physics2D) { + var shadowRootRigidbody = shadowRoot.GetComponent(); + shadowRootRigidbody.MovePosition(transform.position); + shadowRootRigidbody.MoveRotation(transform.rotation.eulerAngles.z); + } else { + var shadowRootRigidbody = shadowRoot.GetComponent(); + shadowRootRigidbody.MovePosition(transform.position); + shadowRootRigidbody.MoveRotation(transform.rotation); + } for (int i = 0, n = shadowTable.Count; i < n; i++) { var pair = shadowTable[i]; diff --git a/spine-unity/Assets/spine-unity/SkeletonExtensions.cs b/spine-unity/Assets/spine-unity/SkeletonExtensions.cs index d1a33f646..0c4d00346 100644 --- a/spine-unity/Assets/spine-unity/SkeletonExtensions.cs +++ b/spine-unity/Assets/spine-unity/SkeletonExtensions.cs @@ -445,17 +445,17 @@ namespace Spine { // Fail loud when skeleton.data is null. Spine.Animation animation = skeleton.data.FindAnimation(animationName); if (animation == null) return; - animation.Apply(skeleton, 0, time, loop, null, 1f, MixPose.Setup, MixDirection.In); + animation.Apply(skeleton, 0, time, loop, null, 1f, MixBlend.Setup, MixDirection.In); } /// Pose a skeleton according to a given time in an animation. public static void PoseSkeleton (this Animation animation, Skeleton skeleton, float time, bool loop = false) { - animation.Apply(skeleton, 0, time, loop, null, 1f, MixPose.Setup, MixDirection.In); + animation.Apply(skeleton, 0, time, loop, null, 1f, MixBlend.Setup, MixDirection.In); } /// Resets Skeleton parts to Setup Pose according to a Spine.Animation's keyed items. public static void SetKeyedItemsToSetupPose (this Animation animation, Skeleton skeleton) { - animation.Apply(skeleton, 0, 0, false, null, 0, MixPose.Setup, MixDirection.Out); + animation.Apply(skeleton, 0, 0, false, null, 0, MixBlend.Setup, MixDirection.Out); } diff --git a/spine-unity/Assets/spine-unity/version.txt b/spine-unity/Assets/spine-unity/version.txt index 2c1099de8..a51afb747 100644 --- a/spine-unity/Assets/spine-unity/version.txt +++ b/spine-unity/Assets/spine-unity/version.txt @@ -1 +1 @@ -This Spine-Unity runtime works with data exported from Spine Editor version: 3.6.xx \ No newline at end of file +This Spine-Unity runtime works with data exported from Spine Editor version: 3.7.xx \ No newline at end of file