From 1fa91daa39a6fc00e97d157e8ad1a90a63998d78 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 1 Sep 2020 10:46:22 +0100 Subject: [PATCH] The Spine Plugin `destroy` method will now no longer remove the Game Objects from the Game Object Factory, or dispose of the Scene Renderer. This means when a Scene is destroyed, it will keep the Game Objects in the factory for other Scene's to use. Fix #5279 `SpinePlugin.gameDestroy` is a new method that is called if the Game instance emits a `destroy` event. It removes the Spine Game Objects from the factory and disposes of the Spine scene renderer. --- plugins/spine/src/SpinePlugin.js | 37 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/plugins/spine/src/SpinePlugin.js b/plugins/spine/src/SpinePlugin.js index 12a7f9a6c..66e0a4dcf 100644 --- a/plugins/spine/src/SpinePlugin.js +++ b/plugins/spine/src/SpinePlugin.js @@ -411,6 +411,8 @@ var SpinePlugin = new Class({ eventEmitter.once('shutdown', this.shutdown, this); eventEmitter.once('destroy', this.destroy, this); + + this.game.events.once('destroy', this.gameDestroy, this); }, /** @@ -1095,15 +1097,6 @@ var SpinePlugin = new Class({ { this.shutdown(); - if (this.sceneRenderer) - { - this.sceneRenderer.dispose(); - } - - this.pluginManager.removeGameObject('spine', true, true); - this.pluginManager.removeGameObject('spineContainer', true, true); - - this.pluginManager = null; this.game = null; this.scene = null; this.systems = null; @@ -1112,9 +1105,33 @@ var SpinePlugin = new Class({ this.spineTextures = null; this.json = null; this.textures = null; - this.sceneRenderer = null; this.skeletonRenderer = null; this.gl = null; + }, + + /** + * The Game that owns this plugin is being destroyed. + * + * Dispose of the Scene Renderer and remove the Game Objects. + * + * @method SpinePlugin#gameDestroy + * @private + * @since 3.50.0 + */ + gameDestroy: function () + { + this.destroy(); + + if (this.sceneRenderer) + { + this.sceneRenderer.dispose(); + } + + this.sceneRenderer = null; + this.pluginManager = null; + + this.pluginManager.removeGameObject('spine', true, true); + this.pluginManager.removeGameObject('spineContainer', true, true); } });