mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Allow overwrite initialize + logs.
This commit is contained in:
parent
f1aa76570f
commit
dac38e5843
@ -79,7 +79,7 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize and instantiate the BoundingBoxFollower colliders. This is method checks if the BoundingBoxFollower has already been initialized for the skeleton instance and slotName and prevents overwriting unless it detects a new setup.</summary>
|
/// Initialize and instantiate the BoundingBoxFollower colliders. This is method checks if the BoundingBoxFollower has already been initialized for the skeleton instance and slotName and prevents overwriting unless it detects a new setup.</summary>
|
||||||
public void Initialize () {
|
public void Initialize (bool overwrite = false) {
|
||||||
if (skeletonRenderer == null)
|
if (skeletonRenderer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -89,7 +89,9 @@ namespace Spine.Unity {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Don't reinitialize if the setup did not change.
|
// Don't reinitialize if the setup did not change.
|
||||||
if (colliderTable.Count > 0 && slot != null // Slot is set and colliders already populated.
|
if (!overwrite
|
||||||
|
&&
|
||||||
|
colliderTable.Count > 0 && slot != null // Slot is set and colliders already populated.
|
||||||
&&
|
&&
|
||||||
skeletonRenderer.skeleton == slot.Skeleton // Skeleton object did not change.
|
skeletonRenderer.skeleton == slot.Skeleton // Skeleton object did not change.
|
||||||
&&
|
&&
|
||||||
@ -119,7 +121,7 @@ namespace Spine.Unity {
|
|||||||
var boundingBoxAttachment = attachment as BoundingBoxAttachment;
|
var boundingBoxAttachment = attachment as BoundingBoxAttachment;
|
||||||
|
|
||||||
if (BoundingBoxFollower.DebugMessages && attachment != null && boundingBoxAttachment == null)
|
if (BoundingBoxFollower.DebugMessages && attachment != null && boundingBoxAttachment == null)
|
||||||
Debug.Log("BoundingBoxFollower tried to follow a slot that contains non-boundingbox attachments: " + slotName);
|
Debug.Log("BoundingBoxFollower tried to follow a slot that contains non-boundingbox attachments: " + slotName);
|
||||||
|
|
||||||
if (boundingBoxAttachment != null) {
|
if (boundingBoxAttachment != null) {
|
||||||
var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, slot, gameObject, isTrigger);
|
var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, slot, gameObject, isTrigger);
|
||||||
@ -206,13 +208,23 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
if (bbAttachment == null) {
|
if (bbAttachment == null) {
|
||||||
currentCollider = null;
|
currentCollider = null;
|
||||||
|
currentAttachment = null;
|
||||||
|
currentAttachmentName = null;
|
||||||
} else {
|
} else {
|
||||||
currentCollider = colliderTable[bbAttachment];
|
PolygonCollider2D foundCollider;
|
||||||
currentCollider.enabled = true;
|
colliderTable.TryGetValue(bbAttachment, out foundCollider);
|
||||||
|
if (foundCollider != null) {
|
||||||
|
currentCollider = foundCollider;
|
||||||
|
currentCollider.enabled = true;
|
||||||
|
currentAttachment = bbAttachment;
|
||||||
|
currentAttachmentName = nameTable[bbAttachment];
|
||||||
|
} else {
|
||||||
|
currentCollider = null;
|
||||||
|
currentAttachment = bbAttachment;
|
||||||
|
currentAttachmentName = null;
|
||||||
|
if (BoundingBoxFollower.DebugMessages) Debug.LogFormat("Collider for BoundingBoxAttachment named '{0}' was not initialized. It is possibly from a new skin. currentAttachmentName will be null. You may need to call BoundingBoxFollower.Initialize(overwrite: true);", bbAttachment.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentAttachment = bbAttachment;
|
|
||||||
currentAttachmentName = currentAttachment == null ? null : nameTable[bbAttachment];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user