Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions cocos/spine/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export class Skeleton extends UIRenderer {
public paused = false;
protected _enumSkins: EnumType = Enum({});
protected _enumAnimations: EnumType = Enum({});
protected attachUtil: AttachUtil;
protected attachUtil: AttachUtil | null = null;
protected _socketNodes: Map<number, Node> = new Map();
protected _cachedSockets: Map<string, number> = new Map<string, number>();

Expand Down Expand Up @@ -339,8 +339,8 @@ export class Skeleton extends UIRenderer {
this._instance = new spine.SkeletonInstance();
this._instance.dtRate = this._timeScale * timeScale;
this._instance.isCache = this.isAnimationCached();
this.attachUtil = new AttachUtil();
}
this.attachUtil = new AttachUtil();
}

/**
Expand Down Expand Up @@ -569,7 +569,9 @@ export class Skeleton extends UIRenderer {
}
this._sockets = val;
this._updateSocketBindings();
this.attachUtil.init(this);
if (!JSB && this.attachUtil) {
this.attachUtil.init(this);
}
}

/**
Expand Down Expand Up @@ -726,7 +728,10 @@ export class Skeleton extends UIRenderer {
this._cleanMaterialCache();
this._vBuffer = null;
this._iBuffer = null;
this.attachUtil.reset();
if (!JSB) {
this.attachUtil?.reset();
this.attachUtil = null;
}
this._slotTextures?.clear();
this._slotTextures = null;
this._cachedSockets.clear();
Expand Down Expand Up @@ -811,7 +816,7 @@ export class Skeleton extends UIRenderer {
this._updateUseTint();
this._indexBoneSockets();
this._updateSocketBindings();
this.attachUtil.init(this);
this.attachUtil!.init(this);
this._preCacheMode = this._cacheMode;
}

Expand Down Expand Up @@ -1130,7 +1135,7 @@ export class Skeleton extends UIRenderer {
}
this._curFrame = frames[frameIdx];
if (this._curFrame !== undefined) {
this.attachUtil.updateSkeletonBones(this._curFrame.boneInfos);
this.attachUtil!.updateSkeletonBones(this._curFrame.boneInfos);
}
if (frameCache.isCompleted && frameIdx >= frames.length) {
this._playCount++;
Expand Down Expand Up @@ -1367,7 +1372,7 @@ export class Skeleton extends UIRenderer {
*/
public syncAttachedNode (): void {
// sync attached node matrix
this.attachUtil._syncAttachedNode();
this.attachUtil?._syncAttachedNode();
}

/**
Expand Down
1 change: 0 additions & 1 deletion platforms/native/engine/jsb-spine-skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ const cacheManager = require('./jsb-cache-manager');

this._indexBoneSockets();
this._updateSocketBindings();
this.attachUtil.init(this);
this._preCacheMode = this._cacheMode;

if (this.defaultSkin && this.defaultSkin !== '') {
Expand Down
Loading