浏览代码

[unity] Copy properties when cloning a MeshAttachment as a linked mesh.

pharan 7 年之前
父节点
当前提交
cc57b680af
共有 1 个文件被更改,包括 13 次插入6 次删除
  1. 13 6
      spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs

+ 13 - 6
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);
 		}
 
 		/// <summary>
@@ -1030,7 +1030,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
 		#region Runtime Linked MeshAttachments
 		/// <summary>
 		/// Returns a new linked mesh linked to this MeshAttachment. It will be mapped to the AtlasRegion provided.</summary>
-		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)