mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
Fix the socket target in Spine is not functioning correctly (#16572)
This commit is contained in:
@@ -48,8 +48,7 @@ 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;
|
||||
@@ -57,6 +56,10 @@ export class AttachUtil {
|
||||
this._syncAttachedNode();
|
||||
}
|
||||
|
||||
updateSkeletonBones (bones: FrameBoneInfo[]): void {
|
||||
this._skeletonBones = bones;
|
||||
}
|
||||
|
||||
reset (): void {
|
||||
this._isInitialized = false;
|
||||
this._skeletonBones = null;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user