Skip to content

Commit

Permalink
[ts][pixi-v7][pixi-v8] Add removeSlotObjects to remove all slot objec…
Browse files Browse the repository at this point in the history
…ts. Closes #2696.
  • Loading branch information
davidetan committed Jan 24, 2025
1 parent b443dd1 commit c6ffb37
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spine-ts/spine-pixi-v7/src/Spine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,16 @@ export class Spine extends Container {
this.slotsObject.delete(slot);
}

/**
* Removes all PixiJS containers attached to any slot.
*/
public removeSlotObjects () {
for (const [, slotObject] of this.slotsObject) {
slotObject.container.removeFromParent();
}
this.slotsObject.clear();
}

private verticesCache: NumberArrayLike = Utils.newFloatArray(1024);
private clippingSlotToPixiMasks: Record<string, Graphics> = {};
private pixiMaskCleanup (slot: Slot) {
Expand Down
10 changes: 10 additions & 0 deletions spine-ts/spine-pixi-v8/src/Spine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,16 @@ export class Spine extends ViewContainer {
}
}

/**
* Removes all PixiJS containers attached to any slot.
*/
public removeSlotObjects () {
Object.entries(this._slotsObject).forEach(([slotName, slotObject]) => {
if (slotObject) slotObject.container.removeFromParent();
delete this._slotsObject[slotName];
});
}

/**
* Returns a container attached to a slot, or undefined if no container is attached.
*
Expand Down

0 comments on commit c6ffb37

Please sign in to comment.