diff --git a/plugins/spine/src/SpinePlugin.js b/plugins/spine/src/SpinePlugin.js index aecd05402..dc6ba07b0 100644 --- a/plugins/spine/src/SpinePlugin.js +++ b/plugins/spine/src/SpinePlugin.js @@ -15,8 +15,6 @@ var SpineGameObject = require('./gameobject/SpineGameObject'); var SpineContainer = require('./container/SpineContainer'); var NOOP = require('../../../src/utils/NOOP'); -// Plugin specific instance of the Spine Scene Renderer -var sceneRenderer; /** * @classdesc @@ -463,14 +461,15 @@ var SpinePlugin = new Class({ } }; - if (!sceneRenderer) - { + var sceneRenderer = this.renderer.spineSceneRenderer; + if (!sceneRenderer) { sceneRenderer = new Spine.webgl.SceneRenderer(this.renderer.canvas, this.gl, true); sceneRenderer.batcher.setBlendMode = setBlendMode; sceneRenderer.shapes.setBlendMode = setBlendMode; + this.renderer.spineSceneRenderer = sceneRenderer; } - // All share the same instance + // All scene share the same instance this.sceneRenderer = sceneRenderer; this.skeletonRenderer = sceneRenderer.skeletonRenderer; this.skeletonDebugRenderer = sceneRenderer.skeletonDebugRenderer; @@ -1136,12 +1135,13 @@ var SpinePlugin = new Class({ this.pluginManager = null; + var sceneRenderer = this.renderer.spineSceneRenderer; + if (sceneRenderer) { sceneRenderer.dispose(); - sceneRenderer = null; } - + this.renderer.spineSceneRenderer = null; this.sceneRenderer = null; } diff --git a/src/plugins/PluginManager.js b/src/plugins/PluginManager.js index f96675869..b54be0506 100644 --- a/src/plugins/PluginManager.js +++ b/src/plugins/PluginManager.js @@ -369,7 +369,8 @@ var PluginManager = new Class({ { // Plugin is freshly loaded PluginCache.register(key, plugin, mapping, true); - + } + if (this.scenePlugins.indexOf(key) === -1) { this.scenePlugins.push(key); } else if (!fromLoader && PluginCache.hasCore(key))