[csharp] Port of commit 14b3170 "Keep slot deform when changing the attachment if the new attachment is compatible with the deform.", see #1896.

This commit is contained in:
Harald Csaszar 2021-05-28 12:34:57 +02:00
parent 14b317008b
commit e7533dff0f

View File

@ -135,14 +135,18 @@ namespace Spine {
/// <summary>The current attachment for the slot, or null if the slot has no attachment.</summary>
get { return attachment; }
/// <summary>
/// Sets the slot's attachment and, if the attachment changed, resets <see cref="AttachmentTime"/> and clears
/// <see cref="Deform">.</summary>
/// Sets the slot's attachment and, if the attachment changed, resets <see cref="AttachmentTime"/> and clears the <see cref="Deform"/>.
/// The deform is not cleared if the old attachment has the same <see cref="VertexAttachment.DeformAttachment"/> as the specified
/// attachment.</summary>
/// <param name="value">May be null.</param>
set {
if (attachment == value) return;
attachment = value;
if (!(value is VertexAttachment) || !(this.attachment is VertexAttachment)
|| ((VertexAttachment)value).DeformAttachment != ((VertexAttachment)this.attachment).DeformAttachment) {
deform.Clear();
}
this.attachment = value;
attachmentTime = bone.skeleton.time;
deform.Clear(false);
}
}