Merge pull request #5766 from xiamidaxia/scenePlugins

Spine plugin multiple game instances support
This commit is contained in:
Richard Davey 2021-09-21 11:36:01 +01:00 committed by GitHub
commit 9cfbe65bfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View file

@ -15,8 +15,6 @@ var SpineGameObject = require('./gameobject/SpineGameObject');
var SpineContainer = require('./container/SpineContainer'); var SpineContainer = require('./container/SpineContainer');
var NOOP = require('../../../src/utils/NOOP'); var NOOP = require('../../../src/utils/NOOP');
// Plugin specific instance of the Spine Scene Renderer
var sceneRenderer;
/** /**
* @classdesc * @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 = new Spine.webgl.SceneRenderer(this.renderer.canvas, this.gl, true);
sceneRenderer.batcher.setBlendMode = setBlendMode; sceneRenderer.batcher.setBlendMode = setBlendMode;
sceneRenderer.shapes.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.sceneRenderer = sceneRenderer;
this.skeletonRenderer = sceneRenderer.skeletonRenderer; this.skeletonRenderer = sceneRenderer.skeletonRenderer;
this.skeletonDebugRenderer = sceneRenderer.skeletonDebugRenderer; this.skeletonDebugRenderer = sceneRenderer.skeletonDebugRenderer;
@ -1136,12 +1135,13 @@ var SpinePlugin = new Class({
this.pluginManager = null; this.pluginManager = null;
var sceneRenderer = this.renderer.spineSceneRenderer;
if (sceneRenderer) if (sceneRenderer)
{ {
sceneRenderer.dispose(); sceneRenderer.dispose();
sceneRenderer = null;
} }
this.renderer.spineSceneRenderer = null;
this.sceneRenderer = null; this.sceneRenderer = null;
} }

View file

@ -369,7 +369,8 @@ var PluginManager = new Class({
{ {
// Plugin is freshly loaded // Plugin is freshly loaded
PluginCache.register(key, plugin, mapping, true); PluginCache.register(key, plugin, mapping, true);
}
if (this.scenePlugins.indexOf(key) === -1) {
this.scenePlugins.push(key); this.scenePlugins.push(key);
} }
else if (!fromLoader && PluginCache.hasCore(key)) else if (!fromLoader && PluginCache.hasCore(key))