From 369cda43355abd47bf0032318ff14e200b748fac Mon Sep 17 00:00:00 2001 From: pharan Date: Wed, 18 Jan 2017 15:54:33 +0800 Subject: [PATCH] [unity] Minor interface consistency fixes. --- .../Arrays/ArraysSubmeshSetMeshGenerator.cs | 18 +++++++++++++++++- .../Arrays/ArraysSubmeshedMeshGenerator.cs | 1 + .../Mesh Generation/ISubmeshedMeshGenerator.cs | 3 ++- .../Assets/spine-unity/SkeletonAnimation.cs | 4 ++-- .../Assets/spine-unity/SkeletonAnimator.cs | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshSetMeshGenerator.cs b/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshSetMeshGenerator.cs index 0e228a24f..9c0e6e11a 100644 --- a/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshSetMeshGenerator.cs +++ b/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshSetMeshGenerator.cs @@ -42,7 +42,14 @@ namespace Spine.Unity.MeshGeneration { readonly ExposedList submeshBuffers = new ExposedList(); Material[] sharedMaterials = new Material[0]; - public MeshAndMaterials GenerateMesh (ExposedList instructions, int startSubmesh, int endSubmesh) { + /// + /// Generates a mesh based on a subset of instructions. + /// + /// A UnityEngine.Mesh. + /// A list of SubmeshInstructions. + /// The index of the starting submesh. + /// The exclusive upper bound of the last submesh to be included. + public MeshAndMaterials GenerateMesh (ExposedList instructions, int startSubmesh, int endSubmesh, float scale = 1f) { // STEP 0: Prepare instructions. var paramItems = instructions.Items; currentInstructions.Clear(false); @@ -122,6 +129,15 @@ namespace Spine.Unity.MeshGeneration { this.sharedMaterials = currentInstructions.GetUpdatedMaterialArray(this.sharedMaterials); } + if (scale != 1f) { + for (int i = 0; i < vertexCount; i++) { + meshVertices[i].x *= scale; + meshVertices[i].y *= scale; + //meshVertices[i].z *= scale; + } + + } + // STEP 3: Assign the buffers into the Mesh. smartMesh.Set(this.meshVertices, this.meshUVs, this.meshColors32, workingAttachments, currentInstructions); mesh.bounds = ArraysMeshGenerator.ToBounds(meshBoundsMin, meshBoundsMax); diff --git a/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshedMeshGenerator.cs b/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshedMeshGenerator.cs index 85332491c..691d2e3be 100644 --- a/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshedMeshGenerator.cs +++ b/spine-unity/Assets/spine-unity/Mesh Generation/Arrays/ArraysSubmeshedMeshGenerator.cs @@ -41,6 +41,7 @@ namespace Spine.Unity.MeshGeneration { public List Separators { get { return this.separators; } } #region Settings + // ArraysMeshGenerator.PremultiplyAlpha public float ZSpacing { get; set; } #endregion diff --git a/spine-unity/Assets/spine-unity/Mesh Generation/ISubmeshedMeshGenerator.cs b/spine-unity/Assets/spine-unity/Mesh Generation/ISubmeshedMeshGenerator.cs index eb0c8e4d7..988dac63b 100644 --- a/spine-unity/Assets/spine-unity/Mesh Generation/ISubmeshedMeshGenerator.cs +++ b/spine-unity/Assets/spine-unity/Mesh Generation/ISubmeshedMeshGenerator.cs @@ -44,6 +44,7 @@ namespace Spine.Unity.MeshGeneration { List Separators { get; } float ZSpacing { get; set; } + bool PremultiplyVertexColors { get; set; } bool AddNormals { get; set; } bool AddTangents { get; set; } } @@ -55,7 +56,7 @@ namespace Spine.Unity.MeshGeneration { // Step 3: Call GenerateMesh. You'll get a Mesh and Materials. // Step 4: Put the Mesh in MeshFilter. Put the Materials in MeshRenderer.sharedMaterials. public interface ISubmeshSetMeshGenerator { - MeshAndMaterials GenerateMesh (ExposedList instructions, int startSubmesh, int endSubmesh); + MeshAndMaterials GenerateMesh (ExposedList instructions, int startSubmesh, int endSubmesh, float scale = 1f); float ZSpacing { get; set; } bool PremultiplyVertexColors { get; set; } diff --git a/spine-unity/Assets/spine-unity/SkeletonAnimation.cs b/spine-unity/Assets/spine-unity/SkeletonAnimation.cs index 121443c60..bdf5e072e 100644 --- a/spine-unity/Assets/spine-unity/SkeletonAnimation.cs +++ b/spine-unity/Assets/spine-unity/SkeletonAnimation.cs @@ -163,11 +163,11 @@ namespace Spine.Unity { #endif } - public virtual void Update () { + public void Update () { Update(Time.deltaTime); } - public virtual void Update (float deltaTime) { + public void Update (float deltaTime) { if (!valid) return; diff --git a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs index f4d95eb02..05e6359d6 100644 --- a/spine-unity/Assets/spine-unity/SkeletonAnimator.cs +++ b/spine-unity/Assets/spine-unity/SkeletonAnimator.cs @@ -83,7 +83,7 @@ namespace Spine.Unity { animationTable.Add(a.Name.GetHashCode(), a); } - void Update () { + public void Update () { if (!valid) return; if (layerMixModes.Length < animator.layerCount)