mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
[unity] Copy properties when cloning a MeshAttachment as a linked mesh.
This commit is contained in:
parent
b4707e4441
commit
cc57b680af
@ -956,7 +956,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MeshAttachment GetLinkedClone (this MeshAttachment o, bool inheritDeform = true) {
|
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>
|
/// <summary>
|
||||||
@ -1030,7 +1030,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
|
|||||||
#region Runtime Linked MeshAttachments
|
#region Runtime Linked MeshAttachments
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a new linked mesh linked to this MeshAttachment. It will be mapped to the AtlasRegion provided.</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 (string.IsNullOrEmpty(attachmentName)) throw new System.ArgumentException("attachmentName cannot be null or empty", "attachmentName");
|
||||||
if (region == null) throw new System.ArgumentNullException("region");
|
if (region == null) throw new System.ArgumentNullException("region");
|
||||||
|
|
||||||
@ -1044,10 +1044,17 @@ namespace Spine.Unity.Modules.AttachmentTools {
|
|||||||
|
|
||||||
// 2. (SkeletonJson.cs::ReadAttachment. case: LinkedMesh)
|
// 2. (SkeletonJson.cs::ReadAttachment. case: LinkedMesh)
|
||||||
mesh.Path = newLinkedMeshName;
|
mesh.Path = newLinkedMeshName;
|
||||||
mesh.r = 1f;
|
if (copyOriginalProperties) {
|
||||||
mesh.g = 1f;
|
mesh.r = o.r;
|
||||||
mesh.b = 1f;
|
mesh.g = o.g;
|
||||||
mesh.a = 1f;
|
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
|
//mesh.ParentMesh property call below sets mesh.Width and mesh.Height
|
||||||
|
|
||||||
// 3. Link mesh with parent. (SkeletonJson.cs)
|
// 3. Link mesh with parent. (SkeletonJson.cs)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user