From cc57b680afedb6b8ccfdd5fe6181b0393702dd44 Mon Sep 17 00:00:00 2001 From: pharan Date: Mon, 1 Oct 2018 22:15:08 +0800 Subject: [PATCH] [unity] Copy properties when cloning a MeshAttachment as a linked mesh. --- .../AttachmentTools/AttachmentTools.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs index 344de6b17..cc2f14ee7 100644 --- a/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs +++ b/spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs @@ -956,7 +956,7 @@ namespace Spine.Unity.Modules.AttachmentTools { } public static MeshAttachment GetLinkedClone (this MeshAttachment o, bool inheritDeform = true) { - return o.GetLinkedMesh(o.Name, o.RendererObject as AtlasRegion, inheritDeform); + return o.GetLinkedMesh(o.Name, o.RendererObject as AtlasRegion, inheritDeform, copyOriginalProperties: true); } /// @@ -1030,7 +1030,7 @@ namespace Spine.Unity.Modules.AttachmentTools { #region Runtime Linked MeshAttachments /// /// Returns a new linked mesh linked to this MeshAttachment. It will be mapped to the AtlasRegion provided. - public static MeshAttachment GetLinkedMesh (this MeshAttachment o, string newLinkedMeshName, AtlasRegion region, bool inheritDeform = true) { + public static MeshAttachment GetLinkedMesh (this MeshAttachment o, string newLinkedMeshName, AtlasRegion region, bool inheritDeform = true, bool copyOriginalProperties = false) { //if (string.IsNullOrEmpty(attachmentName)) throw new System.ArgumentException("attachmentName cannot be null or empty", "attachmentName"); if (region == null) throw new System.ArgumentNullException("region"); @@ -1044,10 +1044,17 @@ namespace Spine.Unity.Modules.AttachmentTools { // 2. (SkeletonJson.cs::ReadAttachment. case: LinkedMesh) mesh.Path = newLinkedMeshName; - mesh.r = 1f; - mesh.g = 1f; - mesh.b = 1f; - mesh.a = 1f; + if (copyOriginalProperties) { + mesh.r = o.r; + mesh.g = o.g; + mesh.b = o.b; + mesh.a = o.a; + } else { + mesh.r = 1f; + mesh.g = 1f; + mesh.b = 1f; + mesh.a = 1f; + } //mesh.ParentMesh property call below sets mesh.Width and mesh.Height // 3. Link mesh with parent. (SkeletonJson.cs)