Skip to content

Commit

Permalink
Fix the socket target in Spine is not functioning correctly (#16572)
Browse files Browse the repository at this point in the history
  • Loading branch information
bofeng-song authored Dec 7, 2023
1 parent 6eadc13 commit d25d3b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cocos/spine/attach-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ export class AttachUtil {
init (skeletonComp: Skeleton): void {
this._isInitialized = false;
if (!skeletonComp || skeletonComp.socketNodes?.size === 0) return;
const isCached = skeletonComp.isAnimationCached();
this._skeletonBones = isCached && skeletonComp._curFrame ? skeletonComp._curFrame.boneInfos : skeletonComp._skeleton.bones;
this._skeletonBones = skeletonComp._skeleton.bones;
if (!this._skeletonBones || this._skeletonBones.length < 1) return;
this._socketNodes = skeletonComp.socketNodes;
if (!this._socketNodes || this._socketNodes.size <= 0) return;
this._isInitialized = true;
this._syncAttachedNode();
}

updateSkeletonBones (bones: FrameBoneInfo[]): void {
this._skeletonBones = bones;
}

reset (): void {
this._isInitialized = false;
this._skeletonBones = null;
Expand Down
3 changes: 3 additions & 0 deletions cocos/spine/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,9 @@ export class Skeleton extends UIRenderer {
frameCache.updateToFrame(frameIdx);
}
this._curFrame = frames[frameIdx];
if (this._curFrame !== undefined) {
this.attachUtil.updateSkeletonBones(this._curFrame.boneInfos);
}
if (frameCache.isCompleted && frameIdx >= frames.length) {
this._playCount++;
if (this._playTimes > 0 && this._playCount >= this._playTimes) {
Expand Down
1 change: 1 addition & 0 deletions platforms/native/engine/jsb-spine-skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ const cacheManager = require('./jsb-cache-manager');

assembler.updateRenderData = function (comp) {
comp._render();
comp.syncAttachedNode();
};

// eslint-disable-next-line no-unused-vars
Expand Down

0 comments on commit d25d3b1

Please sign in to comment.