From 263c6278e253322b40f2347b9e5ef2513afca45f Mon Sep 17 00:00:00 2001 From: John Date: Tue, 4 Jul 2017 08:57:38 +0800 Subject: [PATCH] [unity] BoundingBoxFollower also uses active skin. --- .../BoundingBoxFollower.cs | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs b/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs index dbed7f565..74c7029df 100644 --- a/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs +++ b/spine-unity/Assets/spine-unity/Modules/BoundingBoxFollower/BoundingBoxFollower.cs @@ -112,27 +112,10 @@ namespace Spine.Unity { } if (this.gameObject.activeInHierarchy) { - foreach (var skin in skeleton.Data.Skins) { - var attachmentNames = new List(); - skin.FindNamesForSlot(slotIndex, attachmentNames); + foreach (var skin in skeleton.Data.Skins) + AddSkin(skin, skeleton, slotIndex); - foreach (var skinKey in attachmentNames) { - var attachment = skin.GetAttachment(slotIndex, skinKey); - var boundingBoxAttachment = attachment as BoundingBoxAttachment; - - if (BoundingBoxFollower.DebugMessages && attachment != null && boundingBoxAttachment == null) - Debug.Log("BoundingBoxFollower tried to follow a slot that contains non-boundingbox attachments: " + slotName); - - if (boundingBoxAttachment != null) { - var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, slot, gameObject, isTrigger); - bbCollider.enabled = false; - bbCollider.hideFlags = HideFlags.NotEditable; - bbCollider.isTrigger = IsTrigger; - colliderTable.Add(boundingBoxAttachment, bbCollider); - nameTable.Add(boundingBoxAttachment, skinKey); - } - } - } + AddSkin(skeleton.skin, skeleton, slotIndex); } if (BoundingBoxFollower.DebugMessages) { @@ -146,6 +129,28 @@ namespace Spine.Unity { } } + void AddSkin (Skin skin, Skeleton skeleton, int slotIndex) { + var attachmentNames = new List(); + skin.FindNamesForSlot(slotIndex, attachmentNames); + + foreach (var skinKey in attachmentNames) { + var attachment = skin.GetAttachment(slotIndex, skinKey); + var boundingBoxAttachment = attachment as BoundingBoxAttachment; + + if (BoundingBoxFollower.DebugMessages && attachment != null && boundingBoxAttachment == null) + Debug.Log("BoundingBoxFollower tried to follow a slot that contains non-boundingbox attachments: " + slotName); + + if (boundingBoxAttachment != null) { + var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, slot, gameObject, isTrigger); + bbCollider.enabled = false; + bbCollider.hideFlags = HideFlags.NotEditable; + bbCollider.isTrigger = IsTrigger; + colliderTable.Add(boundingBoxAttachment, bbCollider); + nameTable.Add(boundingBoxAttachment, skinKey); + } + } + } + void OnDisable () { if (clearStateOnDisable) ClearState();