(changed: ComponentChanged)
| 210 | this.add(changed); |
| 211 | } |
| 212 | async remove(changed: ComponentChanged) { |
| 213 | this.increaseAsyncId(changed.gameObject.id); |
| 214 | const component = changed.component as Spine; |
| 215 | clearTimeout(component.addHandler); |
| 216 | const armature = this.armatures[changed.gameObject.id]; |
| 217 | |
| 218 | const container = this.renderSystem?.containerManager?.getContainer(changed.gameObject.id); |
| 219 | if (container && armature) { |
| 220 | container.removeChild(armature); |
| 221 | } else { |
| 222 | // console.warn('remove时container不存在'); |
| 223 | } |
| 224 | |
| 225 | if (component.armature) { |
| 226 | // 销毁所有挂载到插槽的 GameObject |
| 227 | component._destroySlotGameObjects(); |
| 228 | component.armature.destroy({ children: true }); |
| 229 | if (!component.keepResource) { |
| 230 | const res = await resource.getResource(component.lastResource); |
| 231 | const imageSrc = res.data?.image?.src || (res.data?.image as any)?.label; |
| 232 | releaseSpineData(res, imageSrc); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | component.armature = null; |
| 237 | delete this.armatures[changed.gameObject.id]; |
| 238 | delete this._spineComponents[changed.gameObject.id]; |
| 239 | if (changed.type === OBSERVER_TYPE.CHANGE) { |
| 240 | // // @ts-ignore |
| 241 | // component.removeAllListeners(); |
| 242 | } |
| 243 | } |
| 244 | } |
no test coverage detected