mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[spine-unity] Fix BoundingBoxFollower type check.
Slots that are set to an `Attachment` that is not a `BoundingBoxAttachment` will treat it as null instead of ignoring it or throwing an exception.
This commit is contained in:
parent
2fdd820da0
commit
5e08751fb8
@ -107,6 +107,12 @@ namespace Spine.Unity {
|
||||
foreach (var attachmentName in attachmentNames) {
|
||||
var attachment = skin.GetAttachment(slotIndex, attachmentName);
|
||||
var boundingBoxAttachment = attachment as BoundingBoxAttachment;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (attachment != null && boundingBoxAttachment == null)
|
||||
Debug.Log("BoundingBoxFollower tried to follow a slot that contains non-boundingbox attachments.");
|
||||
#endif
|
||||
|
||||
if (boundingBoxAttachment != null) {
|
||||
var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, gameObject, true);
|
||||
bbCollider.enabled = false;
|
||||
@ -127,7 +133,6 @@ namespace Spine.Unity {
|
||||
Debug.LogWarning("Bounding Box Follower tried to rebuild as a prefab.");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void ClearColliders () {
|
||||
@ -159,22 +164,31 @@ namespace Spine.Unity {
|
||||
return;
|
||||
|
||||
if (slot != null && slot.Attachment != currentAttachment)
|
||||
SetCurrent((BoundingBoxAttachment)slot.Attachment);
|
||||
MatchAttachment(slot.Attachment);
|
||||
}
|
||||
|
||||
void SetCurrent (BoundingBoxAttachment attachment) {
|
||||
/// <summary>Sets the current collider to match attachment.</summary>
|
||||
/// <param name="attachment">If the attachment is not a bounding box, it will be treated as null.</param>
|
||||
void MatchAttachment (Attachment attachment) {
|
||||
var bbAttachment = attachment as BoundingBoxAttachment;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (attachment != null && bbAttachment == null)
|
||||
Debug.LogWarning("BoundingBoxFollower tried to match a non-boundingbox attachment. It will treat it as null.");
|
||||
#endif
|
||||
|
||||
if (currentCollider != null)
|
||||
currentCollider.enabled = false;
|
||||
|
||||
if (attachment == null) {
|
||||
if (bbAttachment == null) {
|
||||
currentCollider = null;
|
||||
} else {
|
||||
currentCollider = colliderTable[attachment];
|
||||
currentCollider = colliderTable[bbAttachment];
|
||||
currentCollider.enabled = true;
|
||||
}
|
||||
|
||||
currentAttachment = attachment;
|
||||
currentAttachmentName = currentAttachment == null ? null : attachmentNameTable[attachment];
|
||||
currentAttachment = bbAttachment;
|
||||
currentAttachmentName = currentAttachment == null ? null : attachmentNameTable[bbAttachment];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user