[ts][pixi-v7][pixi-v8] Add removeSlotObjects to remove all slot objects. Closes #2696.

This commit is contained in:
Davide Tantillo 2025-01-24 15:45:24 +01:00
parent b443dd1e29
commit c6ffb37250
2 changed files with 20 additions and 0 deletions

View File

@ -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) {

View File

@ -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.
*